The ability to define a field once, and have it appear repeatedly in a form, allowing the input of multiple values.
Specifically, I'd like this functionality for the page path field type, and also the file field type, but support for other fields would be nice to have as well.
Discussed this with Piotr (Gabrys) a while ago… and apparently it is technically possible, so I'm hoping that this is still something that Wikidot will consider implementing.
Useful for:
- Making multiple links to other pages using pagepath, e.g. sport:football linking to 30 different players, and sport:soccer linking to 13 different players, but only one field is shown at a time, as needed, rather than showing about 50 on the page and not using them all.
- Uploading multiple files in one form, just by defining the file field type once. Say you want to let people upload images using the data form, but you don't know how many they will upload. Once one is uploaded, another button appears to upload another, and another… up to a limit you specify (or: unlimited)
- Special editor for a site. You might not know how many sections to the page there will be, so you specify just one wiki field, and say that it can be used multiple times.
How would it be implemented in GUI?
- Show one form, when text is entered into that form / file is uploading / pagepath pointing to a page, another field appears underneath it… and so on until a limit specified in the data form template.
How would it be implemented in terms of showing it on the page using variables?
- I have no idea… I suppose just use %%form_data{fieldname}%% multiple times would work. i.e. as shown below:
[[div class="field-odd"]] %%form_data{fieldname}%% [[/div]]
[[div class="field-even"]] %%form_data{fieldname}%% [[/div]]
[[div class="field-odd"]] %%form_data{fieldname}%% [[/div]]
====
[[form]]
....
[[/form]]
If fieldname is only used once, then it is only shown once, and the rest are ignored. If however you allow a user to use it more than three times (e.g. not specifying a 'max' value), then only the first three occurrences of fieldname will be displayed.
That's probably the simplest way to do it. And the most powerful, as well. You can include the variables as part of a class name, and with a bit of CSS can selectively determine if the field was entered or not… and display:none; it if nothing was entered.
I was about to add a very similar wish, so thanks for having this one! I started a thread for speculating about this on the (apparently now rather quiet) discussion forum at the Projects site. Here's what I said there, just to consolidate:
Shane's solution to have the form automatically add a new row when the indicated field has content is pretty sweet, but may be beyond me. Maybe the wrapping of several fields could be done using something like
tsangk's conditional blocks, which I also don't quite understand.
That said, I'm willing to put in a good amount of time coding and debugging to create a new javascript CSI that would expand on the existing framework for the [[Forms]] module — perhaps similar to the way
James Kanjo has extended the [[newPage]] module here. Though I'm no James or Kenneth, I think I could make some headway, especially with a project giving me deadline pressure.
But — despite my best efforts — I haven't been able to find the code that drives the original [[Forms]], so I'm working in the dark. Is there a place I should be looking?
Thanks!
What you are suggesting isn't possible … there is a huge difference between re-creating a simple module like NewPage and attempting to re-create (or extend) something like data forms.
For one thing, the NewPage module can be used on any page, whilst data forms only function when interpreted as part of a live template so it's a lot more restrictive.
~ Shane (Wikidot Community Admin - Volunteer)
Wikidot: Wikidot Editor, Official Docs
Other: YouTube (gaming, primarily Minecraft)
Hm, I was afraid of that. Good to know.
That said, outside of the process I was suggesting, is the idea for the extended behavior similar enough to yours to leave it paired together in this wish? Or do you see them as different enough to merit a new wish?
Up to you. It seems to me like you're asking for exactly the same thing, but I might be mistaken.
~ Shane (Wikidot Community Admin - Volunteer)
Wikidot: Wikidot Editor, Official Docs
Other: YouTube (gaming, primarily Minecraft)
So essentially, you want to enable arrays in data forms.
Two propositions:
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript