Given a form get the default values from it.

Paramètres

array $defaults: An empty array used to populate the default values.

array $form: The form returned from drupal_get_form().

string $parent_key: The key name of the parent.

1 call to advagg_get_defaults_from_form()
advagg_advagg_changed_files dans ./advagg.advagg.inc
Implements hook_advagg_changed_files().

Fichier

./advagg.advagg.inc, line 636

Code

function advagg_get_defaults_from_form(array &$defaults, array $form, $parent_key = '') {
    foreach (element_children($form) as $key) {
        $values = $form[$key];
        if (isset($values['#value'])) {
            // Grab defaults at this level.
            if (!isset($defaults[$key])) {
                $defaults[$key] = $values['#value'];
            }
            else {
                $defaults[$parent_key . '-' . $key] = $values['#value'];
            }
        }
        elseif (isset($values['#default_value'])) {
            // Grab defaults at this level.
            if (!isset($defaults[$key])) {
                $defaults[$key] = $values['#default_value'];
            }
            else {
                $defaults[$parent_key . '-' . $key] = $values['#default_value'];
            }
        }
        elseif (is_array($values)) {
            // Go deeper if needed.
            advagg_get_defaults_from_form($defaults, $values, $key);
        }
    }
}