You are here

BooleanSettingType.php in UI Patterns Settings 8.2

Same filename and directory in other branches
  1. 8 src/Plugin/UiPatterns/SettingType/BooleanSettingType.php

File

src/Plugin/UiPatterns/SettingType/BooleanSettingType.php
View source
<?php

namespace Drupal\ui_patterns_settings\Plugin\UIPatterns\SettingType;

use Drupal\ui_patterns_settings\Definition\PatternDefinitionSetting;
use Drupal\ui_patterns_settings\Plugin\PatternSettingTypeBase;

/**
 * Checkbox setting type.
 *
 * @UiPatternsSettingType(
 *   id = "boolean",
 *   label = @Translation("true/false")
 * )
 */
class BooleanSettingType extends PatternSettingTypeBase {

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, $value, PatternDefinitionSetting $def, $form_type) {
    $value = $this
      ->getValue($value);
    $form[$def
      ->getName()] = [
      '#type' => 'checkbox',
      '#title' => $def
        ->getLabel(),
      '#description' => $def
        ->getDescription(),
      '#default_value' => $value,
    ];
    $this
      ->handleInput($form[$def
      ->getName()], $def, $form_type);
    return $form;
  }

}

Classes

Namesort descending Description
BooleanSettingType Checkbox setting type.