0

I have a custom form with a button.

function mymodule_get_subscribed_form($form, $form_state) {
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

Now I want render this button on the front page. I've wrote this code in page--front.tpl.php.

print render(drupal_get_form('mymodule_get_subscribed_form'));

It doesn't work with Drupal 7.54, even after clearing the cache.

0

2 Answers 2

0

It might be because of variables being passed by reference. Try this instead:

$form = drupal_get_form('mymodule_get_subscribed_form');
print drupal_render($form);
1
  • I added 'mymodule_get_subscribed_form' => array( 'render element' => 'form', 'file' => 'mymodule.pages.inc', ), to mymodule_theme and it works! Commented Jun 11, 2017 at 15:48
0

I added

'mymodule_get_subscribed_form' => array(
      'render element' => 'form',
      'file' => 'mymodule.pages.inc',
),

to mymodule_theme hook and now it works.

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.