
| Current Path : /var/www/html/c12park/web/modules/contrib/webform/src/Plugin/WebformElement/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/c12park/web/modules/contrib/webform/src/Plugin/WebformElement/Label.php |
<?php
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\webform\WebformSubmissionInterface;
/**
* Provides a 'label' element.
*
* @WebformElement(
* id = "label",
* api = "https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Label.php/class/Label",
* label = @Translation("Label"),
* description = @Translation("Provides an element for displaying the label for a form element."),
* category = @Translation("Markup elements"),
* states_wrapper = TRUE,
* )
*/
class Label extends WebformMarkupBase {
/**
* {@inheritdoc}
*/
protected function defineDefaultProperties() {
return [
'title' => '',
// Form validation.
'required' => FALSE,
// Attributes.
'attributes' => [],
] + parent::defineDefaultProperties();
}
/* ************************************************************************ */
/**
* {@inheritdoc}
*/
public function buildHtml(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
// Unset #required which is not appropriate when displaying a label.
unset($element['#required']);
// Must define #title_display to prevent PHP warnings via the preprocessor.
// @see template_preprocess_form_element_label()
$element += ['#title_display' => NULL];
return parent::buildHtml($element, $webform_submission, $options);
}
/**
* {@inheritdoc}
*/
public function getItemDefaultFormat() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getItemFormats() {
return [];
}
}