开发者

Show same form many times on one page (D7+formapi)

开发者 https://www.devze.com 2023-03-03 11:15 出处:网络
I\'m trying show on views (each row) my custom form. It works, but the form doesn\'t work proper. I need to give to each form different ids.

I'm trying show on views (each row) my custom form. It works, but the form doesn't work proper. I need to give to each form different ids.

hook_forms should help me, but I cannot manage how to use it. If I put print $form into it, I still cannot see my forms.

I'm calling my form like this from the template file:

$form1 = drupal_get_form('votingform_create_decision_form_' . $node->nid开发者_如何学JAVA, $node->nid);
print drupal_render($form1);


Now I got it working:

function hook_forms($form_id, $args) {

  if ($args[0] == 'mymodule_form_') {
    $forms['mymodule_form_' . $args[1]] = array(
      'callback' => 'mymodule_form',
      'callback arguments' => array($args[1]),
    );
  }

  return $forms;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消