Skip to main content
3 of 3
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/

Form submit handler not working

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

  1. Adding '#submit' => 'catalog_request_form_submit', to the_submit_button key
  2. Adding '$form['#submit'] => 'catalog_request_form_submit'; to end of catalog_request_form function
  3. Adding '$form['#submit'][] => 'catalog_request_form_submit'; to end of catalog_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

Ejaz
  • 143
  • 1
  • 8