2

I am trying to create a custom button that modifies a field in a form then saves the form in the same way as the default save button. The following code creates the button but I am having trouble finding where/how to perform the operation that clicking the default save button executes, with validation and updating every field before executing my submit code.

function mymodule_form_alter(&$form, &$form_state, $form_id) {


     if ($form_id == 'submission_node_form') {
         $form['actions']['final_submit'] = array(
            '#type'   => 'submit',
            '#value'  => t('Submit'),
            '#submit' => array('mymodule_form_final_submit')
         );
     }  

}

function mymodule_form_final_submit($form, &$form_state) {

}
1

A simple way is calling drupal_form_submit in your custom module

function mymodule_form_final_submit($form, &$form_state) {

  drupal_form_submit('submission_node_form', $form_state);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.