public function AjaxCssForm::buildForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/ckeditor/tests/modules/src/Form/AjaxCssForm.php \Drupal\ckeditor_test\Form\AjaxCssForm::buildForm()
- 10 core/modules/ckeditor/tests/modules/src/Form/AjaxCssForm.php \Drupal\ckeditor_test\Form\AjaxCssForm::buildForm()
Form constructor.
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 The form structure.
Overrides FormInterface::buildForm
File
- core/
modules/ ckeditor/ tests/ modules/ src/ Form/ AjaxCssForm.php, line 53
Class
- AjaxCssForm
- A form for testing delivery of CSS to CKEditor via AJAX.
Namespace
Drupal\ckeditor_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Create an inline and iframe CKEditor instance so we can test against
// both.
$form['inline'] = [
'#type' => 'container',
'#attached' => [
'library' => [
'ckeditor_test/ajax_css',
],
],
'#children' => $this
->t('Here be dragons.'),
];
$form['iframe'] = [
'#type' => 'text_format',
'#default_value' => $this
->t('Here be llamas.'),
];
// A pair of buttons to trigger the AJAX events.
$form['actions'] = [
'css_inline' => [
'#type' => 'submit',
'#value' => $this
->t('Add CSS to inline CKEditor instance'),
'#ajax' => [
'callback' => [
$this,
'addCssInline',
],
],
],
'css_frame' => [
'#type' => 'submit',
'#value' => $this
->t('Add CSS to iframe CKEditor instance'),
'#ajax' => [
'callback' => [
$this,
'addCssIframe',
],
],
],
'#type' => 'actions',
];
return $form;
}