Skip to content
Snippets Groups Projects
Commit eeb17f32 authored by Pierre Dureau's avatar Pierre Dureau
Browse files

Remove RadiosWidget

parent 76674a38
No related branches found
No related tags found
No related merge requests found
<?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 = "radios",
* label = @Translation("Radios"),
* description = @Translation("A set of radio buttons."),
* prop_types = {
* "enum"
* }
* )
*/
class RadiosWidget extends SourcePluginBase {
/**
* {@inheritdoc}
*/
public function getData(): mixed {
return $this->getSetting('value');
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state): array {
$options = [];
foreach ($this->propDefinition['enum'] as $item) {
$options[$item] = ucwords($item);
}
return [
'value' => [
'#type' => 'radios',
'#default_value' => $this->getSetting('value'),
"#options" => $options,
],
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment