You are here

public function CommerceLicenseInlineEntityFormController::entityForm in Commerce License 7

Overrides EntityInlineEntityFormController::entityForm().

Overrides EntityInlineEntityFormController::entityForm

File

includes/commerce_license.inline_entity_form.inc, line 26
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 entityForm($entity_form, &$form_state) {
  $license = $entity_form['#entity'];

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

    // Restore any form errors and show them above the form.
    if (!empty($form_state['errors'])) {
      $form_errors =& drupal_static('form_set_error', array());
      $form_errors = $form_state['errors'];
      $error_messages = array(
        'error' => array_values($form_errors),
      );
      $_SESSION['messages'] = array_merge_recursive($error_messages, drupal_get_messages());
      $entity_form['messages'] = array(
        '#markup' => theme('status_messages'),
        '#weight' => -99,
      );
    }
  }
  return $entity_form;
}