Skip to content

data-model value norender|* throws Uncaught Error: Invalid model name "*" when csrf token is being generated #2769

Open
@FluffyDiscord

Description

@FluffyDiscord

I have component that first renders with "data-model"="norender|*". If there are errors after first submit, I change the data-model to on(input)|* to basically allow "validation in real time".

Both should be valid data models, as the first one is even listed in Symfony docs.

Immediately after clicking the send button for the first time, the included csrf_protection_controller.js that came with Symfony 7.2 installation throws the following error:

Uncaught Error: Invalid model name "*".
    at Component.set (@symfony_ux-live-component_dist_live_controller__js.js?v=2893b870:1698:13)
    at extended.updateModelFromElementEvent (@symfony_ux-live-component_dist_live_controller__js.js?v=2893b870:2799:20)
    at extended.handleChangeEvent (@symfony_ux-live-component_dist_live_controller__js.js?v=2893b870:2756:10)
    at HTMLDivElement.callback (@symfony_ux-live-component_dist_live_controller__js.js?v=2893b870:2570:52)
    at generateCsrfToken (csrf_protection_controller.js:36:19)
    at HTMLDocument.<anonymous> (csrf_protection_controller.js:6:5)

The form works, the CSRF controller does set the cookie (or at least it's visible in requests headers the component makes), so everything seems to be working.

I noticed this by chance in production, as I was checking out my new fancy form.

Symfony 7.2
symfony/stimulus-bundle: 2.25.2
symfony/ux-live-component: 2.25.2
symfony/ux-turbo: 2.25.2
symfony/ux-twig-component: 2.25.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions