By numfar85 on
I am working with a simple form and want to make a submit function, but I don't know how to make sure that my function will be called when I push the submit button I have defined for my form.
Currently this is my form builder function:
function _molmeth_add_form($form_state) {
$form = array();
// This is where form elements etc. get added
$form['adding_textarea'] = array(
'#type' => 'textarea',
);
$form['add_button'] = array(
'#type' => 'submit',
'#value' => t('Add protocol'),
);
return $form;
}
And this is my submit function:
function _molmeth_form_submit($form, &$form_state) {
db_set_active('protocols');
db_insert('trashy')
->fields(array(
'test' => 2,
))
->execute();
drupal_set_message(t('Your form has been saved.'));
db_set_active('default');
}
I am neither sure if the function actually gets called nor if the code inside the function actually works.
Comments
I am using the same function
I am using the same function which you have written, i have just changed the module name with test.
For testing purpose,weather the submit function is getting called or not.I am printing dummy text.
Its working for me.
Turns out it wasn't being
Turns out it wasn't being called, I had to change the name of the submit function for it to work.
Thanks for the
it was very useful.