function _authorize_filetransfer_connection_settings_set_defaults
_authorize_filetransfer_connection_settings_set_defaults(&$element, $key, array $defaults)
Sets the default settings on a file transfer connection form recursively.
The default settings for the file transfer connection forms are saved in the database. The settings are stored as a nested array in the case of a settings form that has fieldsets or otherwise uses a nested structure. Therefore, to properly add defaults, we need to walk through all the children form elements and process those defaults recursively.
Parameters
$element: Reference to the Form API form element we're operating on.
$key: The key for our current form element, if any.
array $defaults: The default settings for the file transfer backend we're operating on.
File
- includes/authorize.inc, line 176
- Helper functions and form handlers used for the authorize.php script.
Code
function _authorize_filetransfer_connection_settings_set_defaults(&$element, $key, array $defaults) { // If we're operating on a form element which isn't a fieldset, and we have // a default setting saved, stash it in #default_value. if (!empty($key) && isset($defaults[$key]) && isset($element['#type']) && $element['#type'] != 'fieldset') { $element['#default_value'] = $defaults[$key]; } // Now, we walk through all the child elements, and recursively invoke // ourself on each one. Since the $defaults settings array can be nested // (because of #tree, any values inside fieldsets will be nested), if // there's a subarray of settings for the form key we're currently // processing, pass in that subarray to the recursive call. Otherwise, just // pass on the whole $defaults array. foreach (element_children($element) as $child_key) { _authorize_filetransfer_connection_settings_set_defaults($element[$child_key], $child_key, ((isset($defaults[$key]) && is_array($defaults[$key])) ? $defaults[$key] : $defaults)); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!authorize.inc/function/_authorize_filetransfer_connection_settings_set_defaults/7.x