You are here

function _field_defaults_ui_submit in Field Defaults 7.2

Same name and namespace in other branches
  1. 8 field_defaults.module \_field_defaults_ui_submit()
  2. 7 field_defaults.module \_field_defaults_ui_submit()

Submit handler for field ui form

1 string reference to '_field_defaults_ui_submit'
field_defaults_form_field_ui_field_edit_form_alter in ./field_defaults.module
Implements hook_form_FORM_ID_alter().

File

./field_defaults.module, line 116
field_defaults.module

Code

function _field_defaults_ui_submit($form, &$form_state) {
  $update_defaults = $form_state['values']['update_defaults']['field_defaults_update'];
  $field = $form_state['values']['instance']['field_name'];
  if ($update_defaults && isset($form_state['values'][$field])) {
    $field_translate = FALSE;
    $languages = $form_state['values']['update_defaults']['field_defaults_lang'];
    if ($languages == 'field_translation') {
      $default_language = language_default();
      $languages = array(
        $default_language->language => $default_language->name,
      );
      $field_translate = TRUE;
    }
    $batch = array(
      'entity_type' => $form_state['values']['instance']['entity_type'],
      'bundle' => $form_state['values']['instance']['bundle'],
      'field' => $field,
      'default_value' => $form_state['values'][$field][LANGUAGE_NONE],
      'languages' => $languages,
      'field_translation' => $field_translate,
      'redirect' => $form_state['redirect'],
      'no_overwrite' => $form_state['values']['update_defaults']['field_defaults_no_overwrite'],
    );

    // update the defaults
    field_defaults_batch_run($batch);
  }
}