Browse Source

Merge pull request #257 from nigelgbanks/7.x-system-settings-form-default-value

Added function to simplify system settings forms that utilize AJAX.
pull/258/merge
Jonathan Green 12 years ago
parent
commit
f898f20f59
  1. 21
      includes/utilities.inc

21
includes/utilities.inc

@ -537,3 +537,24 @@ function islandora_directory_exists_message($path) {
} }
return $image . $message; return $image . $message;
} }
/**
* Gets the default value for the given system_settings_form() element.
*
* Checks the $form_state for the default value if not it checks variable_get().
* Assumes #tree is FALSE. This is only really required for elements that utilize
* AJAX, as their value can change before the submit actually takes place.
*
* @param string $name
* The name of the system settings form element.
* @param mixed $default_value
* The default value for the system settings form element.
* @param array $form_state
* The Drupal form state.
*
* @return mixed
* The default value for use in a the system_settings_form().
*/
function islandora_system_settings_form_default_value($name, $default_value, array &$form_state) {
return isset($form_state['values'][$name]) ? $form_state['values'][$name] : variable_get($name, $default_value);
}

Loading…
Cancel
Save