You are here

public function EditColumnModalForm::submitModalFormAjax in Dynamic Layouts 8

File

src/Form/EditColumnModalForm.php, line 174

Class

EditColumnModalForm
EditColumnModalForm class.

Namespace

Drupal\dynamic_layouts\Form

Code

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('#edit_column_modal_form', $form));
  }
  else {
    $row_id = $form_state
      ->getValue(Constants::ROW_ID);
    $column_id = $form_state
      ->getValue(Constants::COLUMN_ID);
    if ($entity_id = $form_state
      ->getValue(Constants::ENTITY_ID)) {
      $this
        ->updateValues($entity_id, $row_id, $column_id, $form_state, $response);
    }
    $response
      ->addCommand(new CloseModalDialogCommand());
  }
  return $response;
}