public function JobForm::ajaxLanguageSelect in Translation Management Tool 8
Ajax callback to fetch the supported translator services and rebuild the target / source language dropdowns.
File
- src/
Form/ JobForm.php, line 746
Class
- JobForm
- Form controller for the job edit forms.
Namespace
Drupal\tmgmt\FormCode
public function ajaxLanguageSelect(array $form, FormStateInterface $form_state) {
$message = $this
->getConflictingItemsMessage($this->entity);
$replace = $form_state
->getUserInput()['_triggering_element_name'] == 'source_language' ? 'target_language' : 'source_language';
$response = new AjaxResponse();
$response
->addCommand(new ReplaceCommand('#tmgmt-ui-translator-wrapper', $form['translator_wrapper']));
$response
->addCommand(new ReplaceCommand('#tmgmt-ui-' . str_replace('_', '-', $replace), $form['info'][$replace]));
if ($message) {
$response
->addCommand(new InvokeCommand('.existing-items', 'removeClass', array(
'hidden',
)));
$response
->addCommand(new ReplaceCommand('.existing-items > div', $message));
}
else {
$response
->addCommand(new InvokeCommand('.existing-items', 'addClass', array(
'hidden',
)));
$response
->addCommand(new ReplaceCommand('.existing-items > div', ''));
}
return $response;
}