Details.php in Webform 6.x
File
src/Plugin/WebformElement/Details.php
View source
<?php
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\webform\WebformSubmissionInterface;
class Details extends ContainerBase {
protected function defineDefaultProperties() {
return [
'help' => '',
'help_title' => '',
'description' => '',
'more' => '',
'more_title' => '',
'title_display' => '',
'help_display' => '',
'open' => FALSE,
'summary_attributes' => [],
] + parent::defineDefaultProperties();
}
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
parent::prepare($element, $webform_submission);
if (isset($element['#webform_key'])) {
$element['#attributes']['data-webform-key'] = $element['#webform_key'];
}
$element['#attached']['library'][] = 'webform/webform.element.details';
}
public function getItemDefaultFormat() {
return 'details';
}
public function getElementSelectorOptions(array $element) {
$title = $this
->getAdminLabel($element);
$name = $element['#webform_key'];
return [
"details[data-webform-key=\"{$name}\"]" => $title . ' [' . $this
->getPluginLabel() . ']',
];
}
}