disable submit button on form

Is there a way to disable the submit button on a form? I see the form component has a disabled method, but it just disables the fields on the form. I looked for a disableSubmit method or something similar and I don't see anything. I'm sure there must be a way to accomplish it and I'm just overlooking it.
public function form(Form $form): Form
{
return $form->schema([
...my form..
]);
}
public function form(Form $form): Form
{
return $form->schema([
...my form..
]);
}
4 Replies
DrByte
DrByte12mo ago
Under what conditions do you want it disabled? Like: do you want it to load up as disabled until all field-validations pass (instead of the button firing the validations when clicked, as it does by default) Or do you want to disable/enable it based on various other conditions? Is your goal to actually prevent submission? Or is it to create a visual cue that something needs to be addressed yet before the user can submit?
Jon Mason
Jon MasonOP12mo ago
I think in this case the goal would be to prevent submission entirely. May sound weird, but I have a form that the user can submit, but then after they've submitted it, I just want them to be able to view what was submitted without being able to change it. My thought was to just have it be the disabled form instead of creating another view.
DrByte
DrByte12mo ago
Hmmm ... reminds me of the Edit page on a Resource: it re-displays the submitted form unless code is added to redirect to Home. But it doesn't disable the button. Or, wait, does it load the View page, which is a read-only version of the submitted data. I forget now because I always do a redirect back to the Table after edits. And a Resource that has both View and Edit pages will use the Form in read-only mode for the View, unless and Infolist is defined, in which case that's used for the View page.
Jon Mason
Jon MasonOP12mo ago
yeah it's basically the same as the edit page on a resource, but it's a livewire component, not a resource. Same concept though. I'm using that in other places in my app which works great to just display the info without allowing it to be edited.
Want results from more Discord servers?
Add your server