function tmgmt_smartling_add_to_job_form_validate in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 tmgmt_smartling.module \tmgmt_smartling_add_to_job_form_validate()
Validate "Add to job" tmgmt_smartling checkout job form part.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state:
1 call to tmgmt_smartling_add_to_job_form_validate()
- tmgmt_smartling_tmgmt_job_edit_form_validate in ./
tmgmt_smartling.module - Validate tmgmt_smartling checkout job form.
File
- ./
tmgmt_smartling.module, line 466 - Contains
Code
function tmgmt_smartling_add_to_job_form_validate(array &$form, FormStateInterface $form_state) {
$settings = $form_state
->getValue('settings');
if (!empty($settings['add_to_job_tab']['container']['job_info']['due_date']) && $settings['add_to_job_tab']['container']['job_info']['due_date'] instanceof DrupalDateTime && $settings['add_to_job_tab']['container']['job_info']['due_date']
->getTimeStamp() < time()) {
$form_state
->setError($form['translator_wrapper']['settings']['add_to_job_tab']['container']['job_info']['due_date'], t('Due date can not be in the past.'));
}
if (empty($settings['add_to_job_tab'])) {
$form_state
->setError($form['translator_wrapper']['settings']['add_to_job_tab'], t('There are no available Smartling jobs.'));
}
if (empty($settings['add_to_job_tab']['container']['job_id'])) {
$form_state
->setError($form['translator_wrapper']['settings']['add_to_job_tab'], t('Please, select the Smartling job.'));
}
}