You are here

public function LayoutParagraphsBehavior::ajaxUpdateOptions in Layout Paragraphs 2.0.x

Ajax callback - returns the updated layout options form.

Parameters

array $form: The form array.

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

Return value

array The layout options form.

File

src/Plugin/paragraphs/Behavior/LayoutParagraphsBehavior.php, line 200

Class

LayoutParagraphsBehavior
Provides a way to define grid based layouts.

Namespace

Drupal\layout_paragraphs\Plugin\paragraphs\Behavior

Code

public function ajaxUpdateOptions(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $parents = $triggering_element['#parents'];
  array_splice($parents, -1, 1, [
    'config',
  ]);
  $config_form = NestedArray::getValue($form, $parents);
  if (isset($config_form)) {
    return $config_form;
  }
  return [];
}