You are here

public function GridDialog::buildAdvancedStep in CKEditor Bootstrap Grid 2.0.x

Builds the advanced settings step.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array The form part.

1 call to GridDialog::buildAdvancedStep()
GridDialog::buildForm in src/Form/GridDialog.php
Form constructor.

File

src/Form/GridDialog.php, line 330

Class

GridDialog
Creates a grid dialog form for use in CKEditor.

Namespace

Drupal\ckeditor_bs_grid\Form

Code

public function buildAdvancedStep(array $form, FormStateInterface $form_state) {
  $settings = $form_state
    ->get('bs_grid_settings');
  $form['#title'] = $this
    ->t("Advanced Settings");

  // Only show if container is selected.
  if (!empty($settings['add_container'])) {
    $form['container_wrapper_class'] = [
      '#title' => $this
        ->t('Container Wrapper Classes'),
      '#type' => 'textfield',
      '#description' => $this
        ->t('Add classes separated by space. Ex: bg-warning py-5'),
      '#default_value' => $settings['container_wrapper_class'] ?? '',
    ];
    $form['container_class'] = [
      '#title' => $this
        ->t('Container Classes'),
      '#type' => 'textfield',
      '#description' => $this
        ->t('Add classes separated by space. Ex: bg-warning py-5'),
      '#default_value' => $settings['container_class'] ?? '',
    ];
  }
  $form['row_class'] = [
    '#title' => $this
      ->t('Row Classes'),
    '#type' => 'textfield',
    '#description' => $this
      ->t('Add classes separated by space. Ex: bg-warning py-5'),
    '#default_value' => $settings['row_class'] ?? '',
  ];
  for ($i = 1; $i <= $settings['num_columns']; $i++) {
    $form['col_' . $i . '_classes'] = [
      '#title' => $this
        ->t('Col @num classes', [
        '@num' => $i,
      ]),
      '#type' => 'textfield',
      '#default_value' => $settings['col_' . $i . '_classes'] ?? '',
      '#description' => $this
        ->t('Add classes separated by space. Ex: bg-warning py-5'),
    ];
  }
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['back'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Back'),
    '#button_type' => 'primary',
    // No regular submit-handler. This form only works via JavaScript.
    '#submit' => [],
    '#ajax' => [
      'callback' => '::submitBackStep',
      'event' => 'click',
    ],
    '#attributes' => [
      'class' => [
        'js-button-back',
      ],
    ],
  ];
  $form['actions']['save_modal'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#button_type' => 'primary',
    // No regular submit-handler. This form only works via JavaScript.
    '#submit' => [],
    '#ajax' => [
      'callback' => '::submitDialog',
      'event' => 'click',
    ],
    '#attributes' => [
      'class' => [
        'js-button-next',
      ],
    ],
  ];
  return $form;
}