Item.php in YAML Form 8
File
src/Plugin/YamlFormElement/Item.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\yamlform\YamlFormSubmissionInterface;
class Item extends ContainerBase {
public function getDefaultProperties() {
return [
'title' => '',
'description' => '',
'title_display' => '',
'description_display' => '',
'field_prefix' => '',
'field_suffix' => '',
'required' => FALSE,
] + $this
->getDefaultBaseProperties();
}
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
parent::prepare($element, $yamlform_submission);
$element['#element_validate'][] = [
get_class($this),
'validate',
];
}
public static function validate(array &$element, FormStateInterface $form_state) {
$name = $element['#name'];
$form_state
->unsetValue($name);
}
}
Classes
Name |
Description |
Item |
Provides a 'item' element. |