F
Filament4mo ago
Darpan

Disable "Create & create another" checkbox in createOptionForm modal (Filament 4.x)

I am using Filament latest 4.x beta and trying to disable the "Create & create another" checkbox in a createOptionForm() modal.
Select::make('categories')
->relationship('categories', 'name')
->multiple()
->preload()
->createOptionForm([
TextInput::make('name')->required(),
])
->createOptionAction(fn ($action) =>
$action->modalWidth('md')
//->createAnother(false) // Not available
);
Select::make('categories')
->relationship('categories', 'name')
->multiple()
->preload()
->createOptionForm([
TextInput::make('name')->required(),
])
->createOptionAction(fn ($action) =>
$action->modalWidth('md')
//->createAnother(false) // Not available
);
Trying to use createAnother(false) throws an error — $action is not a CreateAction. Is there any way to disable that?
3 Replies
toeknee
toeknee4mo ago
GitHub
How to remove or hide "create & create another" button from Modal a...
I want to hide create & create another button while creating new data, In edit page (or modal) it is not showing, how can I make this button hidden while creating & updating thanks in advance
Darpan
DarpanOP4mo ago
Thanks for your reply. I have added following code to
AppServiceProvider
AppServiceProvider
, its working for create record page in resources and simple resource modals but not workin for
createOptionForm()
createOptionForm()
or
createOptionAction()
createOptionAction()
\Filament\Resources\Pages\CreateRecord::disableCreateAnother();
\Filament\Actions\CreateAction::configureUsing(fn(CreateAction $action) => $action->createAnother(false));
\Filament\Resources\Pages\CreateRecord::disableCreateAnother();
\Filament\Actions\CreateAction::configureUsing(fn(CreateAction $action) => $action->createAnother(false));
Am I missing something?
No description
No description
toeknee
toeknee4mo ago
Hmm try
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Actions\Action as FormAction;
use Filament\Actions\Modal\Actions\ModalAction;

Select::configureUsing(function (Select $select) {
if ($select->has('createOptionAction')) {
$existingCreateOptionAction = $select->getCreateOptionAction();
$existingCreateOptionAction->extraModalFooterActions(function (FormAction $action, Select $component): array {
$defaultModalActions = $action->getActions();

return array_filter($defaultModalActions, fn (ModalAction $footerAction) =>
$footerAction->getName() !== 'createAnother'
);
});
}
});
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Actions\Action as FormAction;
use Filament\Actions\Modal\Actions\ModalAction;

Select::configureUsing(function (Select $select) {
if ($select->has('createOptionAction')) {
$existingCreateOptionAction = $select->getCreateOptionAction();
$existingCreateOptionAction->extraModalFooterActions(function (FormAction $action, Select $component): array {
$defaultModalActions = $action->getActions();

return array_filter($defaultModalActions, fn (ModalAction $footerAction) =>
$footerAction->getName() !== 'createAnother'
);
});
}
});

Did you find this page helpful?