public function WebformCodeMirror::form in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformCodeMirror.php \Drupal\webform\Plugin\WebformElement\WebformCodeMirror::form()
Gets the actual configuration webform array to be built.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An associative array contain the element's configuration webform without any default values.
Overrides WebformElementBase::form
File
- src/
Plugin/ WebformElement/ WebformCodeMirror.php, line 124
Class
- WebformCodeMirror
- Provides a 'webform_codemirror' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['default']['default_value']['#type'] = 'webform_codemirror';
$form['default']['default_value']['#rows'] = 3;
$form['codemirror'] = [
'#type' => 'fieldset',
'#title' => $this
->t('CodeMirror settings'),
];
$form['codemirror']['mode'] = [
'#title' => $this
->t('Mode'),
'#type' => 'select',
'#options' => [
'text' => $this
->t('Plain text'),
'yaml' => $this
->t('YAML'),
'html' => $this
->t('HTML'),
'htmlmixed' => $this
->t('HTML (CSS & JavaScript)'),
'css' => 'CSS',
'javascript' => 'JavaScript',
'php' => 'PHP',
'twig' => 'Twig',
],
'#required' => TRUE,
];
$form['codemirror']['wrap'] = [
'#title' => $this
->t('Wrap long lines of text'),
'#type' => 'checkbox',
'#return_value' => TRUE,
];
return $form;
}