content_translation_enable_widget($entity_type, $bundle, array &$form, FormStateInterface $form_state)
Returns a widget to enable content translation per entity bundle.
Backward compatibility layer to support entities not using the language configuration form element.
@todo Remove once all core entities have language configuration.
Parameters
string $entity_type: The type of the entity being configured for translation.
string $bundle: The bundle of the entity being configured for translation.
array $form: The configuration form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- core/modules/content_translation/content_translation.module, line 452
- Allows entities to be translated into different languages.
Code
1 2 3 4 5 6 7 8 9 | function content_translation_enable_widget( $entity_type , $bundle , array & $form , FormStateInterface $form_state ) { $key = $form_state ->get([ 'content_translation' , 'key' ]); $context = $form_state ->get([ 'language' , $key ]) ? : []; $context += [ 'entity_type' => $entity_type , 'bundle' => $bundle ]; $form_state ->set([ 'language' , $key ], $context ); $element = content_translation_language_configuration_element_process( array ( '#name' => $key ), $form_state , $form ); unset( $element [ 'content_translation' ][ '#element_validate' ]); return $element ; } |
Please login to continue.