Skip to content

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

@GrinWay

Description

@GrinWay
Contributor

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)

Activity

carsonbot

carsonbot commented on Sep 21, 2025

@carsonbot

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

carsonbot

carsonbot commented on Oct 5, 2025

@carsonbot

Hello? This issue is about to be closed if nobody replies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationImprovements or additions to documentationStalled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @carsonbot@GrinWay

        Issue actions

          [ComponentWithFormTrait][formValues] Before and after AJAX · Issue #2646 · symfony/ux