Skip to content

Ensure calculated values are set on initial load#97

Merged
dontub merged 1 commit intomainfrom
ensure-calculated-values-on-initial-load
Aug 13, 2025
Merged

Ensure calculated values are set on initial load#97
dontub merged 1 commit intomainfrom
ensure-calculated-values-on-initial-load

Conversation

@dontub
Copy link
Copy Markdown
Collaborator

@dontub dontub commented Aug 4, 2025

Calculated values might not be set on initial form load. By dispatching a change event on a field that has the corresponding AJAX callback a calculation is triggered.

systopia-reference: 29899

@dontub dontub requested a review from jensschuppe August 4, 2025 13:59
@dontub dontub force-pushed the ensure-calculated-values-on-initial-load branch from fed7465 to 2748cc0 Compare August 4, 2025 14:08
Copy link
Copy Markdown
Contributor

@jensschuppe jensschuppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess calculating before rendering the form is not an option in order to not rely on an additional request …?

@dontub
Copy link
Copy Markdown
Collaborator Author

dontub commented Aug 13, 2025

It would be difficult to get the data before submit as it may consist of default values and values in temporary form state data. It would require to parse the JSON schema once to get the default values and a second to time to build the Drupal form.

The implemented solution has also the benefit that the form can be cached without user interaction which especially makes sense when the form specification is generated by a remote system. Otherwise there might be additional delay on the first calculation request.

@dontub dontub merged commit 4714b00 into main Aug 13, 2025
14 checks passed
@dontub dontub deleted the ensure-calculated-values-on-initial-load branch August 13, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants