Hello,
i am looking for help in building an input form using the forms API and hook_form in Drupal 5
Basically creating a list of dates connected to a certain place: The user chooses a date and writes a places. For example 4 Jun 07 - market square
For this purpose I created a custom content type and it all works fine. The problem is that I do not know beforehand how many dates/places are to be added. So I choose jquery (clone()-method) to allow the user to press a Add more.. button to duplicate as many date/place-fields as the user may require.
However I have run into the problem that the name will always be the same: Usually you would have a group of input fields that form an array.
like this would produce an structured array "test" :
<input type="text" name="test[][hello][one]" value="one" />
<input type="text" name="test[][hello][one]" value="two" />
In Forms API it doesn't seem possible to create an element with a name like "test[]" that produces an array like this - is that correct? If so what would be a better approach?
Thanks in advance,
niels
Comments
You might want to check out the AHAH Forms Framework
The AHAH Forms Framework if I understand it correctly is suppose to help with this so you might use it to achieve what you want or if nothing else study the code.
Study the poll.module
It uses the for loop to add in new form fields through an array.