WebformUiElementEditForm.php in Webform 8.5
File
modules/webform_ui/src/Form/WebformUiElementEditForm.php
View source
<?php
namespace Drupal\webform_ui\Form;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformElementHelper;
use Drupal\webform\WebformInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class WebformUiElementEditForm extends WebformUiElementFormBase {
protected $operation = 'update';
public function buildForm(array $form, FormStateInterface $form_state, WebformInterface $webform = NULL, $key = NULL, $parent_key = NULL, $type = NULL) {
$this->element = $webform
->getElementDecoded($key);
if ($this->element === NULL) {
throw new NotFoundHttpException();
}
if ($type = $this
->getRequest()
->get('type')) {
$webform_element = $this
->getWebformElementPlugin();
$related_types = $webform_element
->getRelatedTypes($this->element);
if (!isset($related_types[$type])) {
throw new NotFoundHttpException();
}
$this->originalType = $this->element['#type'];
$this->element['#type'] = $type;
}
$title = WebformElementHelper::getAdminTitle($this->element);
$form['#title'] = $this
->t('Edit @title element', [
'@title' => Markup::create(Xss::filterAdmin($title)),
]);
$this->action = $this
->t('updated');
$form = parent::buildForm($form, $form_state, $webform, $key);
if (!$form_state
->get('default_value_element')) {
$url = new Url('entity.webform_ui.element.delete_form', [
'webform' => $webform
->id(),
'key' => $key,
]);
$this
->buildDialogDeleteAction($form, $form_state, $url);
}
return $form;
}
}