Details.php in YAML Form 8
File
src/Plugin/YamlFormElement/Details.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\yamlform\YamlFormSubmissionInterface;
class Details extends ContainerBase {
public function getDefaultProperties() {
return parent::getDefaultProperties() + [
'open' => FALSE,
];
}
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
parent::prepare($element, $yamlform_submission);
if (isset($element['#yamlform_key'])) {
$element['#attributes']['data-yamlform-key'] = $element['#yamlform_key'];
}
}
public function getElementSelectorOptions(array $element) {
$title = $this
->getAdminLabel($element);
$name = $element['#yamlform_key'];
return [
"details[data-yamlform-key=\"{$name}\"]" => $title . ' [' . $this
->getPluginLabel() . ']',
];
}
}