Posted by bgd on August 23, 2006 at 7:48am
I am working on a module that uses a but of javascript to add dynamic fields to the form. When I hit submit and begin verifying the input via the drupal_get_form("contact_insert_form",$form) call back, I have noticed that my dynamic fields are not added as elements in the $edit variable array. Is there a step I am missing?
I am inserting the dynamic fields using HTML similar to what Drupal generates:
<!-- static-->
<div class="form-item">
<label for="edit-AY1">Attended Conference or Institute:</label>
<input maxlength="4" name="edit[AY1]" id="edit-AY1" size="4" value="" class="form-text" type="text">
</div>
<!--dynamic-->
<div class="form-item"><input name="edit[AY2]" id="edit-AY2" size="4" maxlength="4" class="form-text" type="text"> <label class="option" for="edit-AY2">Year #2</label></div>
<div class="form-item"><input name="edit[AY3]" id="edit-AY3" size="4" maxlength="4" class="form-text" type="text"> <label class="option" for="edit-AY3">Year #3</label></div>Help please!
Comments
I too would like to know how
I too would like to know how to do this. I am writing a module that allows users to add relevant links to the bottom of a document, each link requires text and the link itself. I currently have a set number of link boxes but would rather do it dynamically if possible.
Best I could do
After not hearing from anyone for a few days I just ended up writing a function that pulled the data out of the $_POST variable. I am not super happy with this solution but it works.
Me three would be interested in variable number multiple fields
A plug for the relevancy of this request, and a marker for myself if I find any other solutions.
Is jquery the answer?
~ben
People Who Give a Damn :: http://pwgd.org/ :: Building the infrastructure of a network for everyone
Agaric Design Collective :: http://AgaricDesign.com/ :: Open Source Web Development
benjamin, Agaric
This might be of some help
I found an article by Jeff Eaton that explains the problems and differences between Form API 1.0 and 2.0 for drupal versions 4.7/5.x respectably. Jeff explains three scenarios and I think the one you may be interested in is the "The Form That Builds Itself", about a third of the page down. Jeff is talking about submits but I bet you could add some jQuery magic. I know this is a really old question but still pops up as first result on google when I was looking for similar answers.
BTW, here is the link, http://jeff.viapositiva.net/drupal/dynamic-forms
Cheers,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
Peace,
-mpare
--
Pare Technologies
Drupal Consulting, Themeing, and Module Development
806.781.8324 | 806.733.3025
www.paretech.com
Figure Something Out? Document Your Success!