You are here

function tmgmt_job_form_validate in Translation Management Tool 7

Validation callback for the job checkout form.

@todo Make use of the response object here.

File

ui/includes/tmgmt_ui.pages.inc, line 749
Provides page callbacks and form functions for the Translation Management Tool User Interface module.

Code

function tmgmt_job_form_validate($form, &$form_state) {

  // We need to clone this here so we don't change the job entity in the form
  // state. Otherwise the form will break.
  $backup = clone $form_state[$form_state['entity_type']];
  $job = entity_ui_form_submit_build_entity($form, $form_state);
  $form_state[$form_state['entity_type']] = $backup;

  // Load the selected translator.
  $translator = tmgmt_translator_load($job->translator);

  // Load the metadata wrapper so we can display the selected language.
  $wrapper = entity_metadata_wrapper('tmgmt_job', $job);

  // Check translator availability.
  if (!$translator
    ->isAvailable()) {
    form_set_error('translator', $translator
      ->getNotAvailableReason());
  }
  elseif (!$translator
    ->canTranslate($job)) {
    form_set_error('translator', $translator
      ->getNotCanTranslateReason($job));
  }
}