-
christian.wiedemann authoredchristian.wiedemann authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CheckboxWidget.php 834 B
<?php
declare(strict_types = 1);
namespace Drupal\ui_patterns\Plugin\UiPatterns\Source;
use Drupal\Core\Form\FormStateInterface;
use Drupal\ui_patterns\SourcePluginBase;
/**
* Plugin implementation of the source.
*
* @Source(
* id = "checkbox",
* label = @Translation("Checkbox"),
* description = @Translation("Single checkbox"),
* prop_types = {
* "boolean"
* }
* )
*/
class CheckboxWidget extends SourcePluginBase {
/**
* {@inheritdoc}
*/
public function getData(): mixed {
return (bool) parent::getData();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state): array {
return [
'#type' => 'checkbox',
'#title' => $this->propDefinition['title'],
'#default_value' => $this->getSetting('value'),
];
}
}