Skip to content

Commit

Permalink
nuvolewebGH-316: Cannot include two pattern select elements in same form
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedjo Rogers committed Dec 8, 2020
1 parent cd03369 commit 128b22e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Form/PatternDisplayFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\ui_patterns\Form;

use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SortArray;
use Drupal\ui_patterns\Plugin\PatternSourceBase;

Expand Down Expand Up @@ -30,15 +31,15 @@ trait PatternDisplayFormTrait {
* Default configuration coming form the host form.
*/
public function buildPatternDisplayForm(array &$form, $tag, array $context, array $configuration) {

$pattern_select_id = Html::getUniqueId('patterns-select');
$form['pattern'] = [
'#type' => 'select',
'#empty_value' => '_none',
'#title' => $this->t('Pattern'),
'#options' => $this->patternsManager->getPatternsOptions(),
'#default_value' => isset($configuration['pattern']) ? $configuration['pattern'] : NULL,
'#required' => TRUE,
'#attributes' => ['id' => 'patterns-select'],
'#id' => $pattern_select_id,
];
$form['variants'] = ['#type' => 'container'];

Expand All @@ -53,7 +54,7 @@ public function buildPatternDisplayForm(array &$form, $tag, array $context, arra
'#weight' => 0,
'#states' => [
'visible' => [
'select[id="patterns-select"]' => ['value' => $pattern_id],
'select[id="' . $pattern_select_id . '"]' => ['value' => $pattern_id],
],
],
];
Expand All @@ -63,7 +64,7 @@ public function buildPatternDisplayForm(array &$form, $tag, array $context, arra
'#weight' => 1,
'#states' => [
'visible' => [
'select[id="patterns-select"]' => ['value' => $pattern_id],
'select[id="' . $pattern_select_id . '"]' => ['value' => $pattern_id],
],
],
'settings' => $this->getMappingForm($pattern_id, $tag, $context, $configuration),
Expand Down

0 comments on commit 128b22e

Please sign in to comment.