[support] dinamic form id
Jonathan Hedstrom
jhedstrom at opensourcery.com
Wed Jun 11 16:21:50 UTC 2008
Á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
--
Jonathan Hedstrom OpenSourcery
http://opensourcery.com Technology for Good
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.drupal.org/pipermail/support/attachments/20080611/e425f12c/attachment.pgp
More information about the support
mailing list