In my module's admin configuration page, I have a simple textfield that needs to be filled out before any other input of the form even appears. I thought that this could be done by adding a small button next to the textfield that, when pressed, will perform all the validation that I need (I have already created the functions that will be used) and then additional "select" form elements will be generated. Anyone knows how I can do this?

2 Answers 2

  1. You can use #limit_validation_errors to limit the fields validated when a form is submitted with the button you add.
  2. If you set $form_state['rebuild'] in the validation handler you add for the button the form will be rendered again instead of being submitted.
  3. Then all you have to do it add some logic to the form that will display the extra fields. This can be done with the data in the $form_state.

if its not too complicated business logic you can look into the #states value for FAPI elements. See this is article as an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.