public function EditRowModalForm::submitModalFormAjax in Dynamic Layouts 8
File
- src/
Form/ EditRowModalForm.php, line 123
Class
- EditRowModalForm
- EditRowModalForm class.
Namespace
Drupal\dynamic_layouts\FormCode
public function submitModalFormAjax(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse();
// If there are any form errors, re-display the form.
if ($form_state
->hasAnyErrors()) {
$response
->addCommand(new ReplaceCommand('#modal_example_form', $form));
}
else {
if ($row_classes = $form_state
->getValue('custom_row_classes')) {
// Convert comma separated to array and strip spaces.
$row_classes = explode(',', $row_classes);
$row_classes = array_map('trim', $row_classes);
if (($entity_id = $form_state
->getValue(Constants::ENTITY_ID)) && ($config_entity = $this->entityTypeManager
->getStorage('dynamic_layout')
->load($entity_id))) {
$row_id = $form_state
->getValue(Constants::ROW_ID);
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $config_entity */
$config_entity
->setRowClasses($row_id, $row_classes);
$config_entity
->save();
}
}
$response
->addCommand(new CloseModalDialogCommand());
}
return $response;
}