Loading src/Form/ClBlockDialog.php +2 −2 Original line number Diff line number Diff line Loading @@ -295,10 +295,10 @@ class ClBlockDialog extends FormBase { /** * Render API callback: builds the component data elements. */ public function componentDataProcessCallback(array &$element, FormStateInterface $form_state): array { public function componentDataProcessCallback(array &$element, FormStateInterface $form_state, array $form): array { // Store the array parents for our element so that we can retrieve the // twig block settings in our AJAX callback. $form_state->set('twig_block_array_parents', $element['#array_parents']); $form_state->set([$form['#id'], 'twig_block_array_parents'], $element['#array_parents']); try { $component = $this->componentDiscovery->find($form_state->getValue([ 'attributes', Loading src/Form/ClComponentForm.php +7 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\Component\Component; use Drupal\cl_components\Component\ComponentDiscovery; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; Loading Loading @@ -52,6 +53,7 @@ class ClComponentForm { ], ]; $twig_block_wrapper_id = sprintf('twig-blocks-wrapper--%s', Crypt::randomBytesBase64(8)); $form['component']['variant'] = [ '#type' => 'radios', '#title' => $this->t('Variant'), Loading @@ -59,7 +61,7 @@ class ClComponentForm { '#default_value' => $this->config['component']['variant'] ?? '', '#ajax' => [ 'callback' => [static::class, 'twigBlockAjaxCallback'], 'wrapper' => 'twig-blocks-wrapper', 'wrapper' => $twig_block_wrapper_id, 'effect' => 'fade', ], ]; Loading Loading @@ -102,7 +104,7 @@ class ClComponentForm { $element['#weight'] = 2; // Add the component data to the form via AJAX. $form['component']['twig_blocks_wrapper'] = [ '#prefix' => '<div id="twig-blocks-wrapper">', '#prefix' => '<div id="' . $twig_block_wrapper_id . '">', '#suffix' => '</div>', '#weight' => 5, ]; Loading @@ -118,10 +120,10 @@ class ClComponentForm { /** * Render API callback: builds the component data elements. */ public function componentDataProcessCallback(array &$element, FormStateInterface $form_state): array { public function componentDataProcessCallback(array &$element, FormStateInterface $form_state, array $form): array { // Store the array parents for our element so that we can retrieve the // twig block settings in our AJAX callback. $form_state->set('twig_block_array_parents', $element['#array_parents']); $form_state->set([$form['#id'], 'twig_block_array_parents'], $element['#array_parents']); try { $component = $this->getComponent(); } Loading Loading @@ -168,7 +170,7 @@ class ClComponentForm { * Render API callback: gets the layout settings elements. */ public static function twigBlockAjaxCallback(array $form, FormStateInterface $form_state) { $twig_block_array_parents = $form_state->get('twig_block_array_parents'); $twig_block_array_parents = $form_state->get([$form['#id'], 'twig_block_array_parents']) ?? []; return NestedArray::getValue($form, array_merge($twig_block_array_parents, ['twig_blocks_wrapper'])); } Loading Loading
src/Form/ClBlockDialog.php +2 −2 Original line number Diff line number Diff line Loading @@ -295,10 +295,10 @@ class ClBlockDialog extends FormBase { /** * Render API callback: builds the component data elements. */ public function componentDataProcessCallback(array &$element, FormStateInterface $form_state): array { public function componentDataProcessCallback(array &$element, FormStateInterface $form_state, array $form): array { // Store the array parents for our element so that we can retrieve the // twig block settings in our AJAX callback. $form_state->set('twig_block_array_parents', $element['#array_parents']); $form_state->set([$form['#id'], 'twig_block_array_parents'], $element['#array_parents']); try { $component = $this->componentDiscovery->find($form_state->getValue([ 'attributes', Loading
src/Form/ClComponentForm.php +7 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\Component\Component; use Drupal\cl_components\Component\ComponentDiscovery; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; Loading Loading @@ -52,6 +53,7 @@ class ClComponentForm { ], ]; $twig_block_wrapper_id = sprintf('twig-blocks-wrapper--%s', Crypt::randomBytesBase64(8)); $form['component']['variant'] = [ '#type' => 'radios', '#title' => $this->t('Variant'), Loading @@ -59,7 +61,7 @@ class ClComponentForm { '#default_value' => $this->config['component']['variant'] ?? '', '#ajax' => [ 'callback' => [static::class, 'twigBlockAjaxCallback'], 'wrapper' => 'twig-blocks-wrapper', 'wrapper' => $twig_block_wrapper_id, 'effect' => 'fade', ], ]; Loading Loading @@ -102,7 +104,7 @@ class ClComponentForm { $element['#weight'] = 2; // Add the component data to the form via AJAX. $form['component']['twig_blocks_wrapper'] = [ '#prefix' => '<div id="twig-blocks-wrapper">', '#prefix' => '<div id="' . $twig_block_wrapper_id . '">', '#suffix' => '</div>', '#weight' => 5, ]; Loading @@ -118,10 +120,10 @@ class ClComponentForm { /** * Render API callback: builds the component data elements. */ public function componentDataProcessCallback(array &$element, FormStateInterface $form_state): array { public function componentDataProcessCallback(array &$element, FormStateInterface $form_state, array $form): array { // Store the array parents for our element so that we can retrieve the // twig block settings in our AJAX callback. $form_state->set('twig_block_array_parents', $element['#array_parents']); $form_state->set([$form['#id'], 'twig_block_array_parents'], $element['#array_parents']); try { $component = $this->getComponent(); } Loading Loading @@ -168,7 +170,7 @@ class ClComponentForm { * Render API callback: gets the layout settings elements. */ public static function twigBlockAjaxCallback(array $form, FormStateInterface $form_state) { $twig_block_array_parents = $form_state->get('twig_block_array_parents'); $twig_block_array_parents = $form_state->get([$form['#id'], 'twig_block_array_parents']) ?? []; return NestedArray::getValue($form, array_merge($twig_block_array_parents, ['twig_blocks_wrapper'])); } Loading