-
-
Notifications
You must be signed in to change notification settings - Fork 383
Closed
Closed
Copy link
Labels
BugBug FixBug FixLiveComponentStalledStatus: Needs ReviewNeeds to be reviewedNeeds to be reviewedStatus: Waiting feedbackNeeds feedback from the authorNeeds feedback from the author
Description
Given I have a form with one field which should reset after submit, the field is not updated (emptied in my case) after hitting the enter button. By clicking the submit button, it works.
Any chance to solve this without writing JavaScript?
Thanks for any help!
#[AsLiveComponent]
class Search extends AbstractController
{
use DefaultActionTrait;
use ComponentToolsTrait;
use ComponentWithFormTrait;
#[LiveAction]
public function submit(): void
{
$this->submitForm();
$this->resetForm();
}
protected function instantiateForm(): FormInterface
{
// we can extend AbstractController to get the normal shortcuts
return $this->createForm(DeviceBarcodeType::class, ['barcode' => '']);
}
private function getDataModelValue(): ?string
{
return 'norender|*';
}
}
<div>
{{ form_start(form, {
attr: {
'data-action': 'live#action:prevent',
'data-live-action-param': 'submit',
}
}) }}
{{ form_row(form.barcode) }}
<button
type="submit"
>Submit
</button>
{{ form_end(form) }}
</div>
Metadata
Metadata
Assignees
Labels
BugBug FixBug FixLiveComponentStalledStatus: Needs ReviewNeeds to be reviewedNeeds to be reviewedStatus: Waiting feedbackNeeds feedback from the authorNeeds feedback from the author