function tmgmt_content_form_field_config_edit_form_alter

Implements hook_FORM_ID_alter().

File

sources/content/tmgmt_content.module, line 401
Source plugin for the Translation Management system that handles entities.

Code

function tmgmt_content_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {

  /** @var \Drupal\field\Entity\FieldConfig $field_config */
  $field_config = $form_state
    ->getFormObject()
    ->getEntity();
  $bundle_is_translatable = \Drupal::service('content_translation.manager')
    ->isEnabled($field_config
    ->getTargetEntityTypeId(), $field_config
    ->getTargetBundle());
  $form['tmgmt_content_excluded'] = array(
    '#type' => 'checkbox',
    '#title' => t('Exclude from translations'),
    '#weight' => 0,
    '#default_value' => $field_config
      ->getThirdPartySetting('tmgmt_content', 'excluded', 0),
    '#description' => t('This field will no longer be exported and translated by Translation Management Tool but can still be translated manually.'),
    '#states' => [
      'visible' => [
        ':input[name="translatable"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
    '#access' => $bundle_is_translatable,
  );
  $form['#entity_builders'][] = 'tmgmt_content_entity_builder';
}