public function TextFormat::form in YAML Form 8
Gets the actual configuration form 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 form without any default values..
Overrides YamlFormElementBase::form
File
- src/
Plugin/ YamlFormElement/ TextFormat.php, line 166
Class
- TextFormat
- Provides a 'text_format' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$filters = FilterFormat::loadMultiple();
$options = [];
foreach ($filters as $filter) {
$options[$filter
->id()] = $filter
->label();
}
$form['text_format'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Text format settings'),
];
$form['text_format']['allowed_formats'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Allowed formats'),
'#description' => $this
->t('Please check the formats that are available for this element. Leave blank to allow all available formats.'),
'#options' => $options,
];
$form['text_format']['hide_help'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Hide help'),
'#description' => $this
->t("If checked, the 'About text formats' link will be hidden."),
];
return $form;
}