You are here

public function CkeditorConfigForm::buildForm in CKEditor custom config 8

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 ConfigFormBase::buildForm

File

src/Form/CkeditorConfigForm.php, line 39

Class

CkeditorConfigForm
Class CkeditorConfigController.

Namespace

Drupal\ckeditor_config\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('ckeditor_config.config_form');
  $form['config'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('CKEditor Custom Configuration'),
    '#description' => $this
      ->t("Each row is configuration set in format key=value. Don't use quotes for string values."),
    '#default_value' => $config
      ->get('config'),
  ];
  $manualText = "<code>\n        format_tags=p;h2;h4<br>\n        language = de<br>\n        forcePasteAsPlainText = true<br>\n        uiColor = #AADC6E</code>";
  $form['manual'] = [
    '#prefix' => '<h3>' . $this
      ->t('Example') . '</h3>',
    '#markup' => '<p>' . $manualText . '</p>',
  ];
  $reference_url = 'https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config';
  $form['reference'] = [
    '#prefix' => '<h3>CKEditor reference</h3>',
    '#markup' => '<p>' . $this
      ->t('For more information, visit CKEditor config reference <a href=":reference">@reference</a>', [
      ':reference' => $reference_url,
      '@reference' => $reference_url,
    ]) . '</p>',
  ];
  return parent::buildForm($form, $form_state);
}