content_translation_language_configuration_element_process(array $element, FormStateInterface $form_state, array &$form)
Process callback: Expands the language_configuration form element.
Parameters
array $element: Form API element.
Return value
Processed language configuration element.
File
- core/modules/content_translation/content_translation.module, line 471
- Allows entities to be translated into different languages.
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'] = array( '#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' => array('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; }
Please login to continue.