You are here

function _save_draft_remove_required in Save Draft 7

Make all elements of a form not required.

This is used only when saving drafts, so that users can save an unfinished form that is missing required values.

Parameters

array $elements: An associative array containing the structure of a form.

1 call to _save_draft_remove_required()
save_draft_form_after_build in ./save_draft.module
After build callback for the save draft module.

File

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

Code

function _save_draft_remove_required(array &$elements) {

  // Recurse through all children.
  foreach (element_children($elements) as $key) {
    if (isset($elements[$key]) && $elements[$key]) {
      _save_draft_remove_required($elements[$key]);
    }
  }
  if (!empty($elements['#required'])) {
    $elements['#required'] = FALSE;
  }
}