Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ComponentWithFormTrait][formValues] Before and after AJAX #2646

Open
GrinWay opened this issue Mar 20, 2025 · 0 comments
Open

[ComponentWithFormTrait][formValues] Before and after AJAX #2646

GrinWay opened this issue Mar 20, 2025 · 0 comments
Labels
docs Improvements or additions to documentation

Comments

@GrinWay
Copy link
Contributor

GrinWay commented Mar 20, 2025

The following is not documented and may be confusing:

  1. Before the AJAX request exactly how POST PAYLOAD DATA (by the data-live-props-value) are built to be submitted
  2. After the AJAX what data-live-props-value html attribute will finally be.

I ask this because I came accross with the following:

  1. I have a live form with ChoiceType (datetimes)
  2. AJAX is called (because I pushed the button submit)
  3. My datetimes (ChoiceType) were updated during PRE_SUBMIT event, because of they are dynamic
  4. All the possible choices not contain PAYLOAD[datetime] because it's already doesn't exist among choices, as a result normalized version of the data is null because of the default ChoiceType data transformer
  5. AJAX is finished and I have the old datetime in the data-live-props-value attribute, because it was not changed via frontend but because of the internal logic choices changed (in the PRE_SUBMIT event) I have null model data
  6. FINALLY: I have null model datetime data, but I expected I was the first element of the choice

To solve this I needed to empty formValues before form creation to make data-live-url-value contain first choice element instead of the old currently non-existent element in the choice

But currently it's not clear

In case I did NOT empty formValues before the form creation I would constantly get empty normalized data in my MODEL/ENTITY because data-live-props-value html attribute would constantly contain old non-existent choice unless it was selected from frontend (in this case it would be updated as normal)

@GrinWay GrinWay added the docs Improvements or additions to documentation label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant