function tmgmt_smartling_form_tmgmt_job_edit_form_alter in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 tmgmt_smartling.module \tmgmt_smartling_form_tmgmt_job_edit_form_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
tmgmt_smartling.module, line 357 - Contains
Code
function tmgmt_smartling_form_tmgmt_job_edit_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
// Lock "Submit all N translation jobs with the same settings" and
// add validator/submitter if smartling translator is used.
$translator = $form_state
->getFormObject()
->getEntity()
->getTranslator();
if ($translator
->getPluginId() == 'smartling') {
// This value can be hidden (without type). Lock this value only if it's
// presented as a checkbox.
if (!empty($form['translator_wrapper']['submit_all']['#type'])) {
$form['translator_wrapper']['submit_all']['#value'] = TRUE;
$form['translator_wrapper']['submit_all']['#disabled'] = TRUE;
}
array_unshift($form['#validate'], 'tmgmt_smartling_tmgmt_job_edit_form_validate');
// Don't run TMGMT's core batch operation in case async mode is enabled.
if ($translator
->getSetting('async_mode')) {
$form['actions']['submit']['#submit'] = [
'tmgmt_smartling_tmgmt_job_edit_form_submit',
];
}
else {
array_unshift($form['actions']['submit']['#submit'], 'tmgmt_smartling_tmgmt_job_edit_form_submit');
}
}
}