Skip to content

Commit

Permalink
fix(ServerForm): Fix AJAX error when converting debug flags (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi authored Nov 11, 2023
1 parent 5d7ceca commit 6798e26
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Form/ServerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformState;
Expand Down Expand Up @@ -243,6 +244,19 @@ public function form(array $form, FormStateInterface $formState): array {
return $form;
}

/**
* {@inheritdoc}
*/
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state): void {
// Translate the debug flag from individual checkboxes to the enum value
// that the GraphQL library expects.
$debug_flag = $form_state->getValue('debug_flag');
if (is_array($debug_flag)) {
$form_state->setValue('debug_flag', array_sum($debug_flag));
}
parent::copyFormValuesToEntity($entity, $form, $form_state);
}

/**
* {@inheritdoc}
*
Expand Down Expand Up @@ -274,9 +288,6 @@ public function validateForm(array &$form, FormStateInterface $formState): void
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $formState): void {
// Translate the debug flag from individual checkboxes to the enum value
// that the GraphQL library expects.
$formState->setValue('debug_flag', array_sum($formState->getValue('debug_flag')));
parent::submitForm($form, $formState);

$schema = $formState->getValue('schema');
Expand Down

0 comments on commit 6798e26

Please sign in to comment.