Skip to content

Testing LiveComponent submitForm doc improvement #2509

Closed
@yalit

Description

@yalit

hi,

thanks a lot for the library and especially the TestHelper. However, I found myself in a weird situation when wanting to use the InteractsWithLiveComponents trait as mentioned in the documentation of the LiveComponents as the following is mentioned in it to help test the submission of the form:

// Submit form data
$testComponent
    ->submitForm(['form' => ['input' => 'value']], 'save');

I tried copy-pasting it but I got an error "Form Validation error even if I was absolutely certain that my form values were correct. After some time of trying it out, of searching (I ventured around a csrf issue in test which was not the case), the error was that I was not using the correct form name (my form isn't using a FormType but an EventCreationType and so the code needed is the following:

// Submit form data
$testComponent
    ->submitForm(['event_creation' => [... correct values for my form]], 'save');

Instead, the form was submitted with the default formValues of my component which were indeed not correct ;-)

Maybe the documentation could be updated to include in the comment above the code example what 'form' links to? I'll propose these changes in a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions