Skip to content

Commit 6798e26

Browse files
authored
fix(ServerForm): Fix AJAX error when converting debug flags (#1377)
1 parent 5d7ceca commit 6798e26

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/Form/ServerForm.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Drupal\Core\Ajax\AjaxResponse;
88
use Drupal\Core\Ajax\ReplaceCommand;
99
use Drupal\Core\Entity\EntityForm;
10+
use Drupal\Core\Entity\EntityInterface;
1011
use Drupal\Core\Entity\EntityTypeInterface;
1112
use Drupal\Core\Form\FormStateInterface;
1213
use Drupal\Core\Form\SubformState;
@@ -243,6 +244,19 @@ public function form(array $form, FormStateInterface $formState): array {
243244
return $form;
244245
}
245246

247+
/**
248+
* {@inheritdoc}
249+
*/
250+
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state): void {
251+
// Translate the debug flag from individual checkboxes to the enum value
252+
// that the GraphQL library expects.
253+
$debug_flag = $form_state->getValue('debug_flag');
254+
if (is_array($debug_flag)) {
255+
$form_state->setValue('debug_flag', array_sum($debug_flag));
256+
}
257+
parent::copyFormValuesToEntity($entity, $form, $form_state);
258+
}
259+
246260
/**
247261
* {@inheritdoc}
248262
*
@@ -274,9 +288,6 @@ public function validateForm(array &$form, FormStateInterface $formState): void
274288
* {@inheritdoc}
275289
*/
276290
public function submitForm(array &$form, FormStateInterface $formState): void {
277-
// Translate the debug flag from individual checkboxes to the enum value
278-
// that the GraphQL library expects.
279-
$formState->setValue('debug_flag', array_sum($formState->getValue('debug_flag')));
280291
parent::submitForm($form, $formState);
281292

282293
$schema = $formState->getValue('schema');

0 commit comments

Comments
 (0)