tags:

views:

90

answers:

3

I have a drupal form where users are entering a list of names (via textfields) and I'd like for them to be able to enter as many as they want. Is there some way to make an "input array" with drupal? Any ideas for using Ajax or Ahah to do this?

+1  A: 

this may help?

Adding dynamic form elements using AHAH

i hope.

Tommy
+2  A: 

If you are using CCK you can specify how many of a specific element you like, you can set this to unlimited and it will provide an "add" button beneath the form element.

You could also use a userreference field if the names are from your user base.

Jeremy French
+1  A: 

The easiest way to do that is using a content type and a CCK field, in the field configuration you can set the number of values to unlimited. This will make that when you are looking at the form, a single field will be displayed and a "add another" button which will dynamically add another input element and so on.

If you need to do any processing with the submitted information, you can use the nodeapi hook for capturing the form submition.

If you want to use your own form, then you should use the "#ahah" binding property of forms and add the new elements manually, you'll also need to follow this tutorial that was posted before.

However I strongly suggest you to use a content type since modifying forms asynchronously it's problematic in Drupal 6 and it will probably give you a lot of headaches, see this post for some more hints about how to modify a form with AHAH.

Good luck with it.

Flupkear