I'm looking for help using AHAH to add new fields, much like when you have a node fields with an unlimited number of values. There is a button that says 'Add Another Item'. How can I implement this / where is the code in core that I can examine?
Add another works just like the examples in the Examples project: Use a AHAH-enabled submit button, and build the form with another <whatever> field. Essentially, you're driving it with a submit instead of a select or checkbox like in the example.
The D7 AJAX example has an explicit example of add-more - You may want to roll it for D6 and we'll add it to the Examples.
Thanks for the examples. I wanted to make a form with the ability to add and remove textfields and having come up with some working code I thought I should share it. More details, an example and code can be found here: http://www.petercook.com.au/Drupal6-AHAH-Examples
Thanks for the link! The central location for these examples became the Examples project some years ago... Could you provide a patch over there? It would be great to see this for Drupal 7 as well, as 6 is nearly obsolete.
4 Comments
Using AHAH to add multiple new fields
Submitted by Visitor on
Hello-
I'm looking for help using AHAH to add new fields, much like when you have a node fields with an unlimited number of values. There is a button that says 'Add Another Item'. How can I implement this / where is the code in core that I can examine?
Thanks!
Jeff
Los Angeles, CA
Add-another and node form
Submitted by rfay on
Hi Jeff-
Add another works just like the examples in the Examples project: Use a AHAH-enabled submit button, and build the form with another
<whatever>
field. Essentially, you're driving it with a submit instead of a select or checkbox like in the example.The D7 AJAX example has an explicit example of add-more - You may want to roll it for D6 and we'll add it to the Examples.
-Randy
form example with add/remove textfields
Submitted by Peter Cook on
Thanks for the examples. I wanted to make a form with the ability to add and remove textfields and having come up with some working code I thought I should share it. More details, an example and code can be found here:
http://www.petercook.com.au/Drupal6-AHAH-Examples
Thanks again,
Peter Cook.
Contribute to Examples project
Submitted by rfay on
Thanks for the link! The central location for these examples became the Examples project some years ago... Could you provide a patch over there? It would be great to see this for Drupal 7 as well, as 6 is nearly obsolete.
Thanks!
-Randy