You are here

public static function SettingsFormBuilder::layoutForm in UI Patterns Settings 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsFormBuilder.php \Drupal\ui_patterns_settings\Form\SettingsFormBuilder::layoutForm()

Build pattern settings fieldset.

Parameters

array $form: Form array.

\Drupal\ui_patterns\Definition\PatternDefinition $definition: The pattern definition.

array $configuration: The pattern configuration.

1 call to SettingsFormBuilder::layoutForm()
ui_patterns_settings_ui_patterns_layouts_display_settings_form_alter in ./ui_patterns_settings.module
Implements hook_ui_patterns_layouts_display_settings_form_alter().

File

src/Form/SettingsFormBuilder.php, line 24

Class

SettingsFormBuilder
Build settings in manage display form.

Namespace

Drupal\ui_patterns_settings\Form

Code

public static function layoutForm(array &$form, PatternDefinition $definition, array $configuration) {
  $settings = UiPatternsSettings::getPatternDefinitionSettings($definition);
  $form['variant']['#attributes']['class'][] = 'ui-patterns-variant-selector-' . $definition
    ->id();
  if (!empty($settings)) {
    foreach ($settings as $key => $setting) {
      if (empty($setting
        ->getType()) || !$setting
        ->isFormVisible()) {
        continue;
      }
      if (!isset($form['settings'])) {
        $form['settings'] = [
          '#type' => 'fieldset',
          '#title' => t('Settings'),
        ];
      }
      $setting_value = isset($configuration['pattern']['settings'][$key]) ? $configuration['pattern']['settings'][$key] : NULL;
      $settingType = UiPatternsSettings::createSettingType($setting);
      $form['settings'] += $settingType
        ->buildConfigurationForm([], $setting_value);
    }
    SettingsFormBuilder::buildVariantsForm(".ui-patterns-variant-selector-" . $definition
      ->id(), $form['settings'], $definition);
  }
}