You are here

public static function EntityFormProxy::ajax in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::ajax()
  2. 8 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::ajax()
  3. 8.2 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::ajax()

AJAX callback. Returns the rebuilt inline entity form.

Parameters

array $form: The complete form.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

Return value

\Drupal\Core\Ajax\AjaxResponse The AJAX response.

File

src/Plugin/EntityBrowser/Widget/EntityFormProxy.php, line 189

Class

EntityFormProxy
Base class for EB widgets which wrap around an (inline) entity form.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

public static function ajax(array &$form, FormStateInterface $form_state) {
  if ($form_state::hasAnyErrors()) {
    $form['widget']['bundle']['#access'] = FALSE;
  }
  return (new AjaxResponse())
    ->addCommand(new ReplaceCommand('#entity-form', $form['widget']))
    ->addCommand(new PrependCommand('#entity-form', [
    '#type' => 'status_messages',
  ]));
}