public function WebformEntityElementsForm::form in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformEntityElementsForm.php \Drupal\webform\WebformEntityElementsForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
WebformEntityElementsForm.php, line 92
Class
- WebformEntityElementsForm
- Webform manage elements YAML source form.
Namespace
Drupal\webformCode
public function form(array $form, FormStateInterface $form_state) {
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $this
->getEntity();
$t_args = [
':form_api_href' => 'https://www.drupal.org/node/37775',
':render_api_href' => 'https://www.drupal.org/developing/api/8/render',
':yaml_href' => 'https://en.wikipedia.org/wiki/YAML',
];
$form['elements'] = [
'#type' => 'webform_codemirror',
'#mode' => 'yaml',
'#title' => $this
->t('Elements (YAML)'),
'#description' => $this
->t('Enter a <a href=":form_api_href">Form API (FAPI)</a> and/or a <a href=":render_api_href">Render Array</a> as <a href=":yaml_href">YAML</a>.', $t_args) . '<br /><br />' . '<em>' . $this
->t('Please note that comments are not supported and will be removed.') . '</em>',
'#default_value' => $this
->getElementsWithoutWebformTypePrefix($webform
->get('elements')),
'#required' => TRUE,
'#element_validate' => [
'::validateElementsYaml',
],
'#attributes' => [
'style' => 'min-height: 300px',
],
];
$form['token_tree_link'] = $this->tokenManager
->buildTreeElement();
$this->tokenManager
->elementValidate($form);
return parent::form($form, $form_state);
}