You are here

public function CommerceLicenseInlineEntityFormController::entityFormValidate in Commerce License 7

Overrides EntityInlineEntityFormController::entityFormValidate().

Overrides EntityInlineEntityFormController::entityFormValidate

File

includes/commerce_license.inline_entity_form.inc, line 52
Defines the IEF controller for the commerce_license entity type.

Class

CommerceLicenseInlineEntityFormController
@file Defines the IEF controller for the commerce_license entity type.

Code

public function entityFormValidate($entity_form, &$form_state) {
  $license = $entity_form['#entity'];

  // Only validate the form if the license is configurable.
  if ($license
    ->isConfigurable()) {
    $license
      ->formValidate($entity_form, $form_state);

    // If validation failed, save the errors, clear them, and rebuild the form.
    // This allows them to be displayed by entityForm() in a more appropriate
    // place than the top of the page.
    $form_errors =& drupal_static('form_set_error', array());
    if (!empty($form_errors)) {
      drupal_get_messages('error', TRUE);
      $form_state['errors'] = $form_errors;
      $form_errors = array();
      $form_state['rebuild'] = TRUE;
    }
    else {
      $form_state['errors'] = array();
    }
  }
}