Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- 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

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2004-04-01 - MartinGregory
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.