Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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