function content_translation_language_configuration_element_process

Same name and namespace in other branches
  1. 8.9.x core/modules/content_translation/content_translation.module \content_translation_language_configuration_element_process()
  2. 10 core/modules/content_translation/content_translation.module \content_translation_language_configuration_element_process()
  3. 11.x core/modules/content_translation/content_translation.module \content_translation_language_configuration_element_process()

Process callback: Expands the language_configuration form element.

Parameters

array $element: Form API element.

Return value

array Processed language configuration element.

1 call to content_translation_language_configuration_element_process()
content_translation_enable_widget in core/modules/content_translation/content_translation.module
Returns a widget to enable content translation per entity bundle.
1 string reference to 'content_translation_language_configuration_element_process'
content_translation_element_info_alter in core/modules/content_translation/content_translation.module
Implements hook_element_info_alter().

File

core/modules/content_translation/content_translation.module, line 580

Code

function content_translation_language_configuration_element_process(array $element, FormStateInterface $form_state, array &$form) {
    if (empty($element['#content_translation_skip_alter']) && \Drupal::currentUser()->hasPermission('administer content translation')) {
        $key = $element['#name'];
        $form_state->set([
            'content_translation',
            'key',
        ], $key);
        $context = $form_state->get([
            'language',
            $key,
        ]);
        $element['content_translation'] = [
            '#type' => 'checkbox',
            '#title' => t('Enable translation'),
            // For new bundle, we don't know the bundle name yet,
            // default to no translatability.
'#default_value' => $context['bundle'] ? \Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) : FALSE,
            '#element_validate' => [
                'content_translation_language_configuration_element_validate',
            ],
        ];
        $submit_name = isset($form['actions']['save_continue']) ? 'save_continue' : 'submit';
        // Only add the submit handler on the submit button if the #submit property
        // is already available, otherwise this breaks the form submit function.
        if (isset($form['actions'][$submit_name]['#submit'])) {
            $form['actions'][$submit_name]['#submit'][] = 'content_translation_language_configuration_element_submit';
        }
        else {
            $form['#submit'][] = 'content_translation_language_configuration_element_submit';
        }
    }
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.