WebformUiOptionsForm.php in Webform 6.x
File
modules/webform_ui/src/WebformUiOptionsForm.php
View source
<?php
namespace Drupal\webform_ui;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformOptionsForm;
class WebformUiOptionsForm extends WebformOptionsForm {
public function editForm(array $form, FormStateInterface $form_state) {
$form['options'] = [
'#type' => 'webform_options',
'#mode' => 'yaml',
'#title' => $this
->t('Options'),
'#title_display' => 'invisible',
'#description' => $this
->t("Descriptions, which are only applicable to radios and checkboxes, can be delimited using ' -- '."),
'#description_display' => 'before',
'#empty_options' => 10,
'#add_more_items' => 10,
'#default_value' => $this
->getOptions(),
];
return $form;
}
public function afterBuild(array $element, FormStateInterface $form_state) {
return $element;
}
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
if (is_array($values['options'])) {
$entity
->setOptions($values['options']);
unset($values['options']);
}
foreach ($values as $key => $value) {
$entity
->set($key, $value);
}
}
}