I have a custom module with a from, form submit handler and for theme hook

In some case I need to create multiple form elements (textfields for example with name like "user_input_1"-"user_input_n")

What I did is change $form array in form theme hook and render new elements. But these elements are missing in the post and form submit processing form (even if shown on a page). I realize what it might be not appropriate way of creating new form elements in theme hook OR maybe there is something(function) what will allow me to properly prepare new form elements in theme hook on a fly.

Or maybe there is another way as I know how many elements do I need in submit processing function which rebuild the form and doing something like $form_state['storage']['wizard_step'] = 'step3' (multi-step form). But I don't know drupal very well, just started..

Stuck and spend few hours trying to find appropriate way of solving this. Any help appreciated. Thanks

1 Answer 1


Answer is simple: form alter hook allows to manage form content on a fly

  • Hello, and welcome on Drupal Answers. May you expand your answer? As it is, it is not much helpful for future readers.
    – apaderno
    Sep 25, 2012 at 0:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.