function views_ui_standard_override_values

Return the was_defaulted, is_defaulted and revert state of a form.

3 calls to views_ui_standard_override_values()
views_ui_add_item_form_submit in includes/admin.inc
Submit handler for adding new item(s) to a view.
views_ui_config_item_form_remove in includes/admin.inc
Submit handler for removing an item from a view.
views_ui_standard_submit in includes/admin.inc
Basic submit handler applicable to all 'standard' forms.

File

includes/admin.inc, line 2750

Code

function views_ui_standard_override_values($form, $form_state) {
    // Make sure the dropdown exists in the first place.
    if (isset($form_state['values']['override']['dropdown'])) {
        // #default_value is used to determine whether it was the default value or
        // not. So the available options are: $display, 'default' and
        // 'default_revert', not 'defaults'.
        $was_defaulted = $form['override']['dropdown']['#default_value'] === 'defaults';
        $is_defaulted = $form_state['values']['override']['dropdown'] === 'default';
        $revert = $form_state['values']['override']['dropdown'] === 'default_revert';
        if ($was_defaulted !== $is_defaulted && isset($form['#section'])) {
            // We're changing which display these values apply to.
            // Update the #section so it knows what to mark changed.
            $form['#section'] = str_replace('default-', $form_state['display_id'] . '-', $form['#section']);
        }
    }
    else {
        // The user didn't get the dropdown for overriding the default display.
        $was_defaulted = FALSE;
        $is_defaulted = FALSE;
        $revert = FALSE;
    }
    return array(
        $was_defaulted,
        $is_defaulted,
        $revert,
    );
}