public static function WebformTermCheckboxes::processCheckboxes in Webform 8.5
Same name and namespace in other branches
- 6.x src/Element/WebformTermCheckboxes.php \Drupal\webform\Element\WebformTermCheckboxes::processCheckboxes()
Processes a checkboxes form element.
Overrides Checkboxes::processCheckboxes
File
- src/
Element/ WebformTermCheckboxes.php, line 34
Class
- WebformTermCheckboxes
- Provides a webform element for term checkboxes.
Namespace
Drupal\webform\ElementCode
public static function processCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) {
static::setOptions($element);
$element = parent::processCheckboxes($element, $form_state, $complete_form);
if (!\Drupal::moduleHandler()
->moduleExists('taxonomy')) {
return $element;
}
/** @var \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository */
$entity_repository = \Drupal::service('entity.repository');
$tree = static::loadTree($element['#vocabulary']);
if (empty($element['#breadcrumb'])) {
foreach ($tree as $item) {
$item = $entity_repository
->getTranslationFromContext($item);
$element[$item
->id()]['#title'] = $item
->label();
$element[$item
->id()]['#field_prefix'] = str_repeat($element['#tree_delimiter'], $item->depth);
}
}
$element['#attributes']['class'][] = 'js-webform-term-checkboxes';
$element['#attributes']['class'][] = 'webform-term-checkboxes';
if (!empty($element['#scroll'])) {
$element['#attributes']['class'][] = 'webform-term-checkboxes-scroll';
}
$element['#attached']['library'][] = 'webform/webform.element.term_checkboxes';
return $element;
}