By kreilinger on
hello,
i started to create my first module. it should be a customized contact form.
in my modulename.module file i have the following hook_form implementation:
function kontakt_form($form, &$form_state) {
$form["description"] = array(
"#type" => "item",
"#title" => "Some text"
);
$form["name"] = array(
"#type" => "textfield",
"#title" => "Name",
"#description" => "Your full name",
"#required" => TRUE
);
$form["email"] = array(
"#type" => "textfield",
"#title" => "E-Mail",
"#description" => 'Your e-mail adress (e.g. john@doe.net)',
"#required" => TRUE
);
$form["message"] = array(
"#type" => "textarea",
"#title" => "Message",
"#rows" => 5,
"#required" => TRUE
);
$form["send_copy"] = array(
"#type" => "checkbox",
"#title" => "Send me a copy of this form",
"#required" => FALSE
);
$form["submit_btn"] = array(
"#type" => "submit",
"#value" => "Submit"
);
return $form;
}
i've implemented the menu hook to access this form. now, after filling the form with some data, i clicked the submit button, but nothing happened. no post to the server, no action.
i had a look at the html code and inspected the submit button (my first thought was that it maybe rendered a input type="button") but everything was correct.
then i noticed that there is no form-tag in the whole code! so probably i found the reason why the submit button refused to work. but why isn't there a form tag?
Comments
Hi, You need to write the
Hi,
You need to write the separate logic for validation and submit like this :
Hope that helps.
Regards
Sagar
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
thanks for the answer, but i
thanks for the answer, but i already did that.
the form is still not submitting it's content and there is no form-tag in the html code!
How does your menu hook look
How does your menu hook look like? Do you access this form via drupal_get_form()?
Regards,
David
<?phpfunction kontakt_menu()
any ideas why it's not working?
Maked the following
Maked the following correction in your menu hook
now by implement hooks, _validate and _submit you can validate and submit your form
Hope this will submit your form :)
Need Drupal help?
Reach me
Backend Frontend and DevOps.
oh thank you, works pretty
oh thank you, works pretty good now :)
I had the same problem using D7
I had the same problem using D7, it's weird cause the last time i just called the page using page callback in drupal 5 it just work just fine. Any ideas what's going on ?
edit : nvm, found out that in my old app i just called it using drupal_get_form, but not in the menus.
Thank you so much.
Thank you so much it is worked for me.
Thanks boss
Thanks boss, it saved my time a lot :)