You are here

function save_draft_form_after_build in Save Draft 7

After build callback for the save draft module.

This is used to modify the form after it has been submitted, but before it has been validated. This means we can remove required flags if someone has pressed the save draft button.

Parameters

array $element: An associative array containing the structure of a form element. In this case the form.

array $form_state: The form state array.

Return value

array An associative array containing the structure of a form element.

1 string reference to 'save_draft_form_after_build'
save_draft_form_node_form_alter in ./save_draft.module
Implements hook_form_FORM_ID_alter().

File

./save_draft.module, line 245
Main file for the Save Draft module, which adds a 'Save as draft' button to content types.

Code

function save_draft_form_after_build(array $element, array &$form_state) {

  // Check that the form has been submitted.
  if ($form_state['process_input']) {

    // If the save draft button was pressed.
    if (!empty($form_state['triggering_element']['#skip_required_validation'])) {
      _save_draft_remove_required($element);
    }
  }
  return $element;
}