Ámon Tamás wrote:
Hello,
I have a lot of dynamical generated forms in one page. Every form is a block and I used panels module to put these to one page. Depend on the $delta I made different forms.
Some code: function qqplast_block($op = 'list', $delta='0', $edit=array()) { $blocks = array('a lot of arrays not interesting'); switch($op) { case 'list': return $blocks; case 'view': $block['subject'] = $blocks[$delta]['title']; $block['content'] = drupal_get_form('qqplast_altalanos', $delta); return $block; } } function qqplast_altalanos($delta) { $form=array(); $form["delta"] = array( "#type" => "hidden", "#value" => $delta ); $form['ertekek_'.$delta] = array( "#type" => "checkboxes", "#options" => $anyagnevek[$delta], "#default_value" =>'' ); $form['lekerd_tipus'] = array( "#type" => "select", "#options" => _qqplast_get_lekerdezes_tipus($delta) ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); $form['#submit'] = array('qqplast_altalanos_submit' => array()); return $form; }
The only difference is the checkboxes. My problem is the $form_id is always the same. How can I change it dynamically?
The form id is always the same, because you're passing it a static value of 'qqplast_altalanos'...this becomes the form_id. If you need a different id in the form, you can set it manually using
$form['foo']['#id'] = 'any-id-you-want';
Cheers,
Jonathan