public function WebformCompositeSourceForm::form in Webform Composite Tools 8
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/
Form/ WebformCompositeSourceForm.php, line 83
Class
- WebformCompositeSourceForm
- Form handler for the Composite source editing form.
Namespace
Drupal\webform_composite\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$composite = $this->entity;
$description = $this
->t('Key-value pairs MUST be specified as "safe_key: \'Some readable option\'". Use of only alphanumeric characters and underscores is recommended in keys. One option per line. Option groups can be created by using just the group name followed by indented group options.');
$description .= ' ' . $this
->t("Descriptions, which are only applicable to radios and checkboxes, can be delimited using ' -- '.");
$form['source'] = [
'#type' => 'webform_codemirror',
'#mode' => 'yaml',
'#title' => $this
->t('Source (YAML)'),
'#description' => $description,
'#default_value' => $composite
->getElementsRaw(),
];
$form['#attached']['library'][] = 'webform/webform.codemirror.yaml';
return $form;
}