public function LayoutParagraphsWidget::buildLayoutConfigurationFormAjax in Layout Paragraphs 1.0.x
Ajax callback to return a layout plugin configuration form.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse|array The Ajax Response.
File
- src/
Plugin/ Field/ FieldWidget/ LayoutParagraphsWidget.php, line 1988
Class
- LayoutParagraphsWidget
- Entity Reference with Layout field widget.
Namespace
Drupal\layout_paragraphs\Plugin\Field\FieldWidgetCode
public function buildLayoutConfigurationFormAjax(array $form, FormStateInterface $form_state) {
$element = $form_state
->getTriggeringElement();
$parents = $element['#array_parents'];
$parents = array_splice($parents, 0, -2);
if ($entity_form = NestedArray::getValue($form, $parents)) {
$response = new AjaxResponse();
$response
->addCommand(new ReplaceCommand('#' . $this->wrapperId . ' .layout-paragraphs-form', $entity_form));
$response
->addCommand(new InvokeCommand('#' . $this->wrapperId . ' .layout-paragraphs-form input:checked', 'focus'));
$response
->addCommand(new LayoutParagraphsStateResetCommand('#' . $this->wrapperId));
return $response;
}
else {
return [];
}
}