Skip to content

Commit 2e6aacd

Browse files
author
Dominic Tubach
committed
Clear pre schema validation callbacks on form rebuild
1 parent 674084b commit 2e6aacd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Form/AbstractJsonFormsForm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Drupal\Core\Form\FormStateInterface;
2626
use Drupal\json_forms\Form\Util\FieldNameUtil;
2727
use Drupal\json_forms\Form\Util\FormCallbackExecutor;
28+
use Drupal\json_forms\Form\Util\FormCallbackRegistrator;
2829
use Drupal\json_forms\Form\Util\FormValidationUtil;
2930
use Drupal\json_forms\Form\Validation\FormValidationMapperInterface;
3031
use Drupal\json_forms\Form\Validation\FormValidatorInterface;
@@ -122,6 +123,7 @@ protected function buildJsonFormsForm(
122123

123124
if ($formState->isRebuilding()) {
124125
$formState->set('$hasCalcInitField', FALSE);
126+
FormCallbackRegistrator::clearPreSchemaValidationCallbacks($formState);
125127
}
126128

127129
$definition = DefinitionFactory::createDefinition($uiSchema, $jsonSchema);

src/Form/Util/FormCallbackRegistrator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ final class FormCallbackRegistrator {
2626

2727
public const PRE_SCHEMA_VALIDATION_CALLBACKS_PROPERTY_KEY = 'json_forms.pre_schema_validation_callbacks';
2828

29+
public static function clearPreSchemaValidationCallbacks(FormStateInterface $formState): void {
30+
$formState->set(self::PRE_SCHEMA_VALIDATION_CALLBACKS_PROPERTY_KEY, []);
31+
}
32+
2933
/**
3034
* Registers a callback that is executed before JSON schema validation.
3135
*

0 commit comments

Comments
 (0)