Create fields dynamically in custom form

I am building a custom module for Drupal 7. It contains a huge form. I created a jQuery code which modifies the form and adds some new selects, text fields and checkboxes.

When I submit the form I am not able to read data from fields which were added by jQuery.

I downloaded Examples for Developers ( There is one example called Add-more button (ajax_example). It seems that is submits all data, increases a counter, rebuilds whole form with new fields and then rendered form is sent back. Is there any possibility to avoid sending whole form server to client? It is not the fastest solution.

I would like to modify my form using jQuery, submit it, rebuild it and validate it. Each change would not require sending data to server.

Thank you, Martin.


I submit the form I am not able to read data from fields which were added by jQuery

Make sure that you add a name field to your inputs and select elements.

The $_POST['here_is_the_name_which_you_give_to_your_elements'] reads the value of inputed form fields server side.

I decipher that the form will have multiple inputs and selects which are created dynamically. To manage that:

Add [] after the value of the name field. For Eg:

 <input type='text' value='' name='my_custom_input[]' id='this_is_not_reqiured_1'>
 <input type='text' value='' name='my_custom_input[]' id='this_is_not_reqiured_2'>

You can get the value of all the <input> with name = my_custom_input on the server side in an Array via POST or GET.

Note: ID is not needed but you can use and maintain a counter if you need those DOM elements Manipulated.

Need Your Help

LibGdx - Place Actor outside stage

libgdx scene2d

For some reason I can't find an answer for this.

How can I host many identical java web applications?

java hosting glassfish-3 load-balancing cluster-computing

I have a problem. I need to host many (tens, hundreds) of small identical JAVA web applications that have different loads during one time. I want to use Glassfish V3. Do I need to use a load balanc...