function EntityTranslationController::entityFormValidate

Form validation handler for EntityTranslationController::entityFormAlter().

Validates the submitted entity translation metadata.

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php, line 448
Definition of Drupal\translation_entity\EntityTranslationController.

Class

EntityTranslationController
Base class for entity translation controllers.

Namespace

Drupal\translation_entity

Code

function entityFormValidate($form, &$form_state) {
  if (!empty($form_state['values']['translation_entity'])) {
    $translation = $form_state['values']['translation_entity'];

    // Validate the "authored by" field.
    if (!empty($translation['name']) && !($account = user_load_by_name($translation['name']))) {
      form_set_error('translation_entity][name', t('The translation authoring username %name does not exist.', array(
        '%name' => $translation['name'],
      )));
    }

    // Validate the "authored on" field.
    if (!empty($translation['created']) && strtotime($translation['created']) === FALSE) {
      form_set_error('translation_entity][created', t('You have to specify a valid translation authoring date.'));
    }
  }
}