I have been trying to make a form that changes the number of textfields present depending on the value of a selectbox. I have been able to update the form, and get the right number of textfields.

The problem is that everytime I change the selectbox the form gets validated/submitted and values inserted into db. This is not what I wanted, anyone know how to get around this?

I copied most of the code from http://drupal.org/project/examples but the examples here don't do db-inserts/validation so they don't have thisproblem.

Comments

rfay’s picture

I just saw your post today... And it happens that the Drupal 7 AJAX function changed this week, (#684846: AJAX triggered by non-submit element fails if any elements are validated) and the submit function is no longer invoked during the AJAX callback.

I don't completely understand your issue, but if you file an issue against either Drupal or Examples module, as the case may be, I'll help figure it out.

You'd be better with a question like this to:

1. Look for one of the Forms or AJAX maintainers on IRC (See the MAINTAINERS.txt file)
or
2. File a support issue on Examples module
or
3. File a support issue or bug on Drupal.

We all want to see this code work the way it should.

-Randy

lionic’s picture

I used
'#limit_validation_errors' => array()
to solve my problem

petek’s picture

This fixed my problem too.
'#limit_validation_errors' => array(),

Note: Just make sure to put it in the form item array and not the ajax key array.