YamlFormToggles.php in YAML Form 8
File
src/Plugin/YamlFormElement/YamlFormToggles.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\yamlform\YamlFormSubmissionInterface;
class YamlFormToggles extends OptionsBase {
use YamlFormToggleTrait;
public function getDefaultProperties() {
return parent::getDefaultProperties() + [
'toggle_theme' => 'light',
'toggle_size' => 'medium',
'on_text' => '',
'off_text' => '',
];
}
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
parent::prepare($element, $yamlform_submission);
$element['#element_validate'][] = [
get_class($this),
'validateMultipleOptions',
];
}
protected function getElementSelectorInputsOptions(array $element) {
$selectors = $element['#options'];
foreach ($selectors as &$text) {
$text .= ' [' . $this
->t('Toggle') . ']';
}
return $selectors;
}
}