public function TextFormat::form in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/TextFormat.php \Drupal\webform\Plugin\WebformElement\TextFormat::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/ TextFormat.php, line 302
Class
- TextFormat
- Provides a 'text_format' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
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_value' => TRUE,
];
return $form;
}