CreatModel edit getFormActions based on a condition.

I need to run specific checks on different CreateModel's form actions. All i need to do is return "create" , "save and create another" and cancel depending on the condition. Now getCreateFormAction() is available but i cant seem to find other options for "cancel" and "create" Is this built in or do i need to create it from scratch? protected function getFormActions(): array { $user = auth()->user()->phone;
if ($user !== null) { return [ $this->xxxCancel(); ]; } return [ $this->getCreateFormAction(), $this->xxxCreateAndCreateOther(), $this->xxxCancel(); ]; }
2 Replies
dissto
dissto7mo ago
I believe what you are looking for are: $this->getCreateFormAction() and $this->getCancelFormAction(). Check the source code for more details.
gringomutt
gringomuttOP7mo ago
Thank you. I must of gone down the wrong rabit hole. Thank you. For any future readers here is a simple example form the filament page CreateModel
protected function getFormActions(): array
{
$user = auth()->user()->phone;

if ($user === null) {
return [
$this->getCancelFormAction()
];
}
return [
$this->getCreateFormAction(),
$this->getCreateAnotherFormAction(),
$this->getCancelFormAction(),
];

}
protected function getFormActions(): array
{
$user = auth()->user()->phone;

if ($user === null) {
return [
$this->getCancelFormAction()
];
}
return [
$this->getCreateFormAction(),
$this->getCreateAnotherFormAction(),
$this->getCancelFormAction(),
];

}
Want results from more Discord servers?
Add your server