Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a Form using my module, which looks like this, then I've created a _validate & _submit handler (please see the linked file above). Then, in my front page, I printed the form using:

$form = drupal_get_form('mymodule_signin');
print render($form);

But when I'm submitting the form, the validate & submit handlers are not getting called, I'm getting redirected back to the front page. However, I created a submit button but when I was clicking it, the form was not getting submitted, so I submitted the form using jQuery's .submit() method to submit the function!

Can anyone help me why the form was not getting submitted first time, and finally when it was submitted (using javascript) the handler was not getting called? Here goes the template file I used to render the form.

PS. I created an entry in the hook_menu() and when I submit form using this page, the form gets submitted (calls validate handler). But it is not calling validate/submit handler when I submit it in my front page. :(

share|improve this question
Please show your form, validate and submite functions. – BetaRide Mar 26 '12 at 6:16
Can you add this piece of code after printing the form and check ?<?php print drupal_render($form['form_build_id']); print drupal_render($form['form_id']); print drupal_render($form['form_token']); ?> This worked in 6 for me I cannot test it on 7 – GoodSp33d Mar 26 '12 at 6:49
@BetaRide I've provided them, please check the links... @kantu They're printed using drupal_render_children(); – giga Mar 26 '12 at 7:34
Might want to try it on a normal node page as well and see what result you get. There could be problems when the front page is not properly set or something important is missing. – Dooshta Mar 26 '12 at 19:08
@Dooshta it works in normal pages. It just doesn't work when I try to get it in front page using drupal_get_form() – giga Mar 27 '12 at 3:23

I think you should have an element of type submit in your form function.

share|improve this answer
Would the downvoter kindly explain what's wrong with this answer ? – Countzero Mar 26 '12 at 9:54
OK, read the sentence about the submit button. Still, the form not being submitted when clicking the button is not a normal behaviour, and submitting via JQuery will only complicate the problem. – Countzero Mar 26 '12 at 9:57
#submit adds a submit-handler function, right? I had one, (commented on my code now) but no luck! I think the down-voter will explain... – giga Mar 26 '12 at 13:29
#submitat the form level does what you say, but I was talking about a submit button '#type' => 'submit'. – Countzero Mar 26 '12 at 14:35
As per what Countzero said... Dont know if it defaults without it being set but try: $form['button'] = array( '#type' => 'button', '#value' => t('Submit'), '#submit' => array('mymodule_dum_s'), '#executes_submit_callback' => TRUE); } – WestieUK Mar 26 '12 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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