function translation_views_form_alter in Translation Views 8
Implements hook_form_alter().
Add our submit for "source_langcode" submit.
File
- ./
translation_views.module, line 37 - Provide hooks for translation_views module.
Code
function translation_views_form_alter(&$form, FormStateInterface $form_state) {
$form_object = $form_state
->getFormObject();
if (!$form_object instanceof ContentEntityFormInterface) {
return;
}
$entity = $form_object
->getEntity();
$operations = $form_object
->getOperation();
if ($entity instanceof ContentEntityInterface && $entity
->isTranslatable() && count($entity
->getTranslationLanguages()) > 1 && in_array($operations, [
'edit',
'add',
'default',
], TRUE)) {
$form['source_langcode']['submit']['#submit'][] = 'translation_views_content_form_fix_destination';
}
}