Reputation: 1624
I am trying to submit a form using the submit button created like this:
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#weight' => 5,
'#submit' => array('edit_form_submit'),
);
However when the form is submit the
function edit_form_submit($form, &$form_state){
dsm('IM HERE!!!');
}
does not get run.
I have checked the usual things line:
the $form['#form_id'] is 'edit_form' and $form['#type'] is set to 'form'.
I'm not quite stuck on this. I do think it must be a simple overlooked problem but I dont see it.
Any Ideas??
If you require more information please ask.
Upvotes: 0
Views: 152
Reputation: 236
You cant do it in this way , you have to do something like this
function mymodule_myfrom($form, &$form_state){
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#weight' => 5,
);
return $form;
}
function mymodule_myfrom_submit($form, &$form_values){
dsm('IM HERE!!!');
}
To call your form do this
$myfrom=drupal_get_form('mymodule_myfrom');
print drupal_render($myfrom);
to see complete example check out this example module, you can find from example https://drupal.org/project/examples
Also you can check tutorials like this one http://mrphp.com.au/blog/how-make-simple-form-module-drupal
Upvotes: 1