You are here

function entity_translation_translatable_form in Entity Translation 7

Confirm form for changing field translatability.

1 string reference to 'entity_translation_translatable_form'
entity_translation_menu in ./entity_translation.module
Implements hook_menu().

File

./entity_translation.admin.inc, line 507
The entity translation user interface.

Code

function entity_translation_translatable_form($form, &$form_state, $field_name) {
  $field = field_info_field($field_name);
  if ($field['translatable']) {
    $title = t('Are you sure you want to disable translation for this field?');
    $text = t('All occurrences of this field will become <em>untranslatable</em>:');
    if (empty($form_state['input'])) {
      drupal_set_message(t('All the existing field translations will be deleted. This operation cannot be undone.'), 'warning');
    }
  }
  else {
    $title = t('Are you sure you want to enable translation for this field?');
    $text = t('All occurrences of this field will become <em>translatable</em>:');
    $form['options'] = array(
      '#type' => 'fieldset',
      '#title' => t('Migration settings'),
      '#weight' => -10,
    );
    $form['options']['copy_all_languages'] = array(
      '#title' => t('Copy translations'),
      '#description' => t('Copy field data into <em>all</em> existing translations, otherwise data will only be available in the original language.'),
      '#type' => 'checkbox',
      '#default_value' => TRUE,
    );
  }
  $text .= _entity_translation_field_desc($field);
  $text .= t('This operation may take a long time to complete.');

  // We need to keep some information for later processing.
  $form_state['field'] = $field;

  // Store the 'translatable' status on the client side to prevent outdated form
  // submits from toggling translatability.
  $form['translatable'] = array(
    '#type' => 'hidden',
    '#default_value' => $field['translatable'],
  );
  return confirm_form($form, $title, '', $text);
}