You are here

public function LocalTaskItemForm::validateSaveAsComplete in Translation Management Tool 8

Form validate callback for save as completed submit action.

Verify that all items are translated.

File

translators/tmgmt_local/src/Form/LocalTaskItemForm.php, line 391

Class

LocalTaskItemForm
Form controller for the localTaskItem edit forms.

Namespace

Drupal\tmgmt_local\Form

Code

public function validateSaveAsComplete(array &$form, FormStateInterface $form_state) {

  // Loop over all data items and verify that there is a translation in there.
  foreach ($form_state
    ->getValues() as $key => $value) {
    if (is_array($value) && isset($value['translation'])) {
      if (empty($value['translation'])) {
        $form_state
          ->setErrorByName($key . '[translation]', t('Missing translation.'));
      }
    }
  }
}