I'm developing a pretty basic module catalog_request
that creates a form. I'm replacing the form's default submit button <input ..type="submit" />
with a <button ...>click</button>
using following in form definition.
function catalog_request_form($form, &$form_state) {
/**
* form fields here
*/
$form['fieldset_submit']['the_submit_button'] = array(
'#type' => 'markup',
'#prefix' => '<button class="btn submit">',
'#markup' => 'Send Request...',
'#suffix' => '</button>',
);
/* ... */
}
and have defined other two form related functions
function catalog_request_form_validate($form, &$form_state) {
drupal_set_message(t('The form was validated'));
}
function catalog_request_form_submit($form, &$form_state) {
die('submitted');
//drupal_set_message(t('The form was submitted'));
}
The problem
My submit function catalog_request_form_submit
isn't being called. I've read numerous articles online but none resolved my issue. Following didn't work
- Adding
'#submit' => 'catalog_request_form_submit',
tothe_submit_button
key - Adding
'$form['#submit'] => 'catalog_request_form_submit';
to end ofcatalog_request_form
function - Adding
'$form['#submit'][] => 'catalog_request_form_submit';
to end ofcatalog_request_form
function
I've read that adding something along the lines of $form['actions']['#submit'][] = 'custom_function';
could solve the problem but I'm not sure how to adapt it for my form.
I know that having '#type' => 'submit'
for the submit button makes the form work but I want a button
tag.
My problem is exactly When altering the submit button, the form does not work but it doesn't have a solution (only an answer that ignores the question's point)
P.S. I do not develop for drupal frequently so I might be missing something very obvious.
Any help will be greatly appreciated. thanks