public function GridDialog::validateForm in CKEditor Bootstrap Grid 2.0.x
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ GridDialog.php, line 410
Class
- GridDialog
- Creates a grid dialog form for use in CKEditor.
Namespace
Drupal\ckeditor_bs_grid\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Load current settings.
$settings = $form_state
->get('bs_grid_settings');
if ($form_state
->get('step') == 'select') {
$values_to_save = [
'num_columns',
];
}
elseif ($form_state
->get('step') == 'layout') {
$values_to_save = [
'add_container',
'container_type',
'no_gutter',
'breakpoints',
];
}
elseif ($form_state
->get('step') == 'advanced') {
$values_to_save = [
'container_wrapper_class',
'container_class',
'row_class',
];
// Detect changes and set parent to "none".
for ($i = 1; $i <= $settings['num_columns']; $i++) {
$key = 'col_' . $i . '_classes';
$settings[$key] = $form_state
->getValue($key, '');
}
}
foreach ($values_to_save as $save) {
$settings[$save] = $form_state
->getValue($save);
}
$form_state
->set('bs_grid_settings', $settings);
}