Don't submit form on "enter"

Is it possible to stop submitting a form when pressing "enter" ?
10 Replies
JJSanders
JJSanders4mo ago
Does anyone have an Idea on how to do this ?
dhanar98
dhanar984mo ago
protected function mutateFormDataBeforeCreate(array $data): array
{

}
protected function mutateFormDataBeforeCreate(array $data): array
{

}
for this function check the key bindings if the enter button is triggered
JJSanders
JJSanders4mo ago
Do you have a more concrete exemple how this will look?
Matthew
Matthew4mo ago
I believe:
public function create(bool $another = false): void
{
}
public function create(bool $another = false): void
{
}
In your Create Record This overwrites the create method
JJSanders
JJSanders4mo ago
How can you then prevent "enter" to submit in this code?
Matthew
Matthew4mo ago
Oh wait wdym "enter"?
JJSanders
JJSanders4mo ago
I want to prevent that pressing "enter" submits the form
Matthew
Matthew4mo ago
weird, when I press enter, form doesnt submit It could be a JS thing no idee
awcodes
awcodes4mo ago
Um. This is actually how forms work at the browser level. If an input other that select is focused then pressing enter will submit the form. I would also highly recommend against trying to prevent the behavior as doing so would result in accessibility issues since it is the expected behavior.
JJSanders
JJSanders4mo ago
I know. But some users don't know how browsers work. So maybe I should just tell them that this is the way it works in browsers.