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(); ]; }
if ($user !== null) { return [ $this->xxxCancel(); ]; } return [ $this->getCreateFormAction(), $this->xxxCreateAndCreateOther(), $this->xxxCancel(); ]; }
2 Replies
I believe what you are looking for are:
$this->getCreateFormAction()
and $this->getCancelFormAction()
.
Check the source code for more details.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