YamlFormCheckboxesOther.php in YAML Form 8
File
src/Plugin/YamlFormElement/YamlFormCheckboxesOther.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\yamlform\YamlFormSubmissionInterface;
class YamlFormCheckboxesOther extends Checkboxes {
public function getDefaultProperties() {
return parent::getDefaultProperties() + self::getOtherProperties();
}
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
parent::prepare($element, $yamlform_submission);
$element['#element_validate'][] = [
get_class($this),
'validateMultipleOptions',
];
}
public function getElementSelectorOptions(array $element) {
$title = $this
->getAdminLabel($element);
$name = $element['#yamlform_key'];
$selectors = [];
foreach ($element['#options'] as $input_name => $input_title) {
$selectors[":input[name=\"{$name}[checkboxes][{$input_name}]\"]"] = $input_title . ' [' . $this
->t('Checkboxes') . ']';
}
$selectors[":input[name=\"{$name}[other]\"]"] = $title . ' [' . $this
->t('Textfield') . ']';
return [
$title => $selectors,
];
}
}