diable edit form from a action

Hello there I need disable/enable de edit form (save button included) from a custom action button. This button will change one field of the record (1/0) I need to see the form but It cannot be modified without push that button (that change a field of the record Any Ideas? Thank you in advance
1 Reply
LeandroFerreira
like this?
//EditPage.php
public $actionsDisabled = true;

protected function getActions(): array
{
return [

Action::make('toggleActions')
->label($this->actionsDisabled ? 'Enable edition' : 'Disable edition')
->action(fn () => $this->actionsDisabled = !$this->actionsDisabled)
->requiresConfirmation(),

Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}

protected function getFormActions(): array
{
return [
Action::make('save')
->submit('save')
->disabled($this->actionsDisabled),
$this->getCancelFormAction(),
];
}
//EditPage.php
public $actionsDisabled = true;

protected function getActions(): array
{
return [

Action::make('toggleActions')
->label($this->actionsDisabled ? 'Enable edition' : 'Disable edition')
->action(fn () => $this->actionsDisabled = !$this->actionsDisabled)
->requiresConfirmation(),

Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}

protected function getFormActions(): array
{
return [
Action::make('save')
->submit('save')
->disabled($this->actionsDisabled),
$this->getCancelFormAction(),
];
}
Want results from more Discord servers?
Add your server