Question
I have been playing with tables like the ones that are in the Sandbox (to-do and change request).
I have a hurdle between me and what feels like elegant implementation of the kinds of thing I want to do: being able to create the name for the new topic at the time that the user clicks "Create", based on what the user typed into the form ... but not exactly what they typed in.
For example, I want to build a "Customer address database".
In the form, the person wants to type the
CompanyName.
There is, in all likelihood, already a topic called
CompanyName, so the topic for the table entry can't be called that.
I want to call it
AddressDetailsCompanyName, but darned if I can see a way to get from
CompanyName (which they type in) to setting the topic=AddressDetailsCompanyName in the call to the edit script.
Any ideas?
(At the moment I force them to type
AddressDetailsCompanyName, which is a cludge... in the same way that the to-do list tries (unsuccessfully, you will see if you look) to make users type
ItemDoSomething instead of
DoSomething))
Environment
--
MartinGregory - 23 Mar 2004
Answer
You could
JavaScript. Show one field for the company name,
e.g. "XYZ Corp.". Use
JavaScript to compose the topic name
from that, e.g. "AddressDetailsXyzCorp". This can be put
into a hidden (or visible) form field of name "topic".
From a database perspective it might be better to use a
generic topic name, e.g. AddrID123456789 and store the
company name in a TWikiForm field. In your index and query
page, you can show the company name as the link label. A
simple "random" number is the date starting at the year.
See and copy example at
Main.TWikiInstallation
--
PeterThoeny - 27 Mar 2004
You should probably look at the
FormQueryPlugin as well. That has a topic creator script (and tag) that you can use or customise.
--
CrawfordCurrie - 30 Mar 2004
Thanks Crawford, that's an interesting option, though I have to admit slightly scary (in terms of having
to tackle
FormQueryPlugin, and maybe even hack its scripts, just to achieve what I want... I'm no Rod Whitby,
and don't have him to call on!). Of more relevance, perhaps, I've found that Peter's suggestion to take a database perspective
is a wise one leading to a number of elegances and KISS results that I'm happy with at the moment... if it
all works out properly I will document back here...
--
MartinGregory - 01 Apr 2004