You are here

function globallink_form_field_ui_field_edit_form_submit in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink.module \globallink_form_field_ui_field_edit_form_submit()
  2. 7.6 globallink.module \globallink_form_field_ui_field_edit_form_submit()

Update field config for modified bundle field.

1 string reference to 'globallink_form_field_ui_field_edit_form_submit'
globallink_form_field_ui_field_edit_form_alter in ./globallink.module
Implements hook_form_FORM_ID_alter().

File

./globallink.module, line 794
GlobalLink translation module.

Code

function globallink_form_field_ui_field_edit_form_submit($form, &$form_state) {
  $field_name = $form['#instance']['field_name'];
  $entity_type = $form['#instance']['entity_type'];
  $bundle_name = $form['#instance']['bundle'];
  if (!globallink_check_field_configured($bundle_name, $entity_type, $bundle_name, $field_name)) {
    return;
  }
  if ($entity_type != 'node') {
    return;
  }
  if (!globallink_translation_supported($bundle_name)) {
    return;
  }
  if (!isset($form['instance']['globallink_translate_field'])) {
    return;
  }
  $translatable = $form['instance']['globallink_translate_field']['#value'];
  db_update('globallink_field_config')
    ->fields(array(
    'field_label' => $form['instance']['label']['#value'],
    'translatable' => $translatable,
  ))
    ->condition('content_type', $bundle_name, '=')
    ->condition('entity_type', $entity_type, '=')
    ->condition('bundle', $bundle_name, '=')
    ->condition('field_name', $field_name, '=')
    ->execute();

  /*Added these changes for synching up the content type field config changes with the globallinm field config changes. */

  //Check if the field translation has been disabled, and remove it from the globallink field configurations as well.
  $field_translatable = $form_state['field'][$field_name]['und']['field']['translatable'];
  if ($field_translatable == 0) {
    db_delete('globallink_field_config')
      ->condition('field_name', $field_name, '=')
      ->condition('entity_type', $entity_type, '=')
      ->condition('bundle', $bundle_name, '=')
      ->condition('content_type', $bundle_name, '=')
      ->execute();
  }
}