private static function SettingsFormBuilder::buildVariantsForm in UI Patterns Settings 8
Same name and namespace in other branches
- 8.2 src/Form/SettingsFormBuilder.php \Drupal\ui_patterns_settings\Form\SettingsFormBuilder::buildVariantsForm()
Hide all settings which are configured by the variant.
Parameters
string $select_selector: The id of the variant select field.
array $fieldset: The fieldset.
\Drupal\ui_patterns\Definition\PatternDefinition $definition: The pattern definition.
2 calls to SettingsFormBuilder::buildVariantsForm()
- SettingsFormBuilder::displayForm in src/
Form/ SettingsFormBuilder.php - Build pattern settings for display form.
- SettingsFormBuilder::layoutForm in src/
Form/ SettingsFormBuilder.php - Build pattern settings fieldset.
File
- src/
Form/ SettingsFormBuilder.php, line 96
Class
- SettingsFormBuilder
- Build settings in manage display form.
Namespace
Drupal\ui_patterns_settings\FormCode
private static function buildVariantsForm($select_selector, array &$fieldset, PatternDefinition $definition) {
$variants = $definition
->getVariants();
foreach ($variants as $variant) {
$variant_ary = $variant
->toArray();
$settings = isset($variant_ary['settings']) ? $variant_ary['settings'] : [];
foreach ($settings as $name => $setting) {
if (isset($fieldset[$name])) {
// Add an or before a new state begins.
if (isset($fieldset[$name]['#states']['invisible']) && count($fieldset[$name]['#states']['invisible']) != 0) {
$fieldset[$name]['#states']['invisible'][] = 'or';
}
// Hide configured setting.
$fieldset[$name]['#states']['invisible'][][$select_selector]['value'] = $variant
->getName();
}
}
}
}