public function YamlFormEntityAssetsForm::form in YAML Form 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/
YamlFormEntityAssetsForm.php, line 16
Class
- YamlFormEntityAssetsForm
- Provides a form to inject CSS and JS assets.
Namespace
Drupal\yamlformCode
public function form(array $form, FormStateInterface $form_state) {
/** @var \Drupal\yamlform\YamlFormInterface $yamlform */
$yamlform = $this->entity;
$form['css'] = [
'#type' => 'details',
'#title' => $this
->t('Custom CSS'),
'#open' => TRUE,
];
$form['css']['css'] = [
'#type' => 'yamlform_codemirror',
'#mode' => 'css',
'#title' => $this
->t('CSS'),
'#title_display' => 'invisible',
'#description' => $this
->t('Enter custom CSS to be attached to the form.'),
'#default_value' => $yamlform
->getCss(),
];
$form['javascript'] = [
'#type' => 'details',
'#title' => $this
->t('Custom JavaScript'),
'#open' => TRUE,
];
$form['javascript']['javascript'] = [
'#type' => 'yamlform_codemirror',
'#mode' => 'javascript',
'#title' => $this
->t('JavaScript'),
'#title_display' => 'invisible',
'#description' => $this
->t('Enter custom JavaScript to be attached to the form.'),
'#default_value' => $yamlform
->getJavaScript(),
];
return parent::form($form, $form_state);
}