Removing the Create Button in FilamentPHP Resources
In FilamentPHP, the Create button is often treated as a default UI element that appears automatically whenever you register a resource. However, there are scenarios where your application logic dictates that new records should not be created directly from the list view. Perhaps your data is managed via an import process, or the creation workflow happens through a separate admin panel entirely. In these cases, leaving the button active creates confusion and invites users to attempt actions that bypass your intended workflow.
To suppress the create functionality for a specific resource like Customer, you need to intervene at the configuration level within your Resource class. Filament relies on the create method to determine whether the form should be rendered. If this method returns false, the corresponding button and action are removed from the interface.
Consider the following implementation for a Customer resource:
use App\Filament\Resources\CustomerResource;
public static function canCreate(): bool
{
return false;
}
By overriding the canCreate() method and returning false, you explicitly tell Filament to hide the button. This approach is cleaner than trying to conditionally render the view or relying on complex permission checks that might still allow access if not strictly enforced at the UI layer.
Alternatively, if you prefer a more dynamic approach based on environment or role, you can implement conditional logic inside canCreate(). For instance, you might want to disable creation in production environments while keeping it enabled in staging or local setups:
public static function canCreate(): bool
{
return app()->environment('local', 'staging');
}
This pattern ensures that your application's behavior adapts to the deployment context without requiring separate resource definitions.
It is important to note that removing the button does not alter the underlying database or permissions. If a user has the ability to create records via other meansâsuch as API endpoints or direct route accessâthe action remains possible even if the UI button is gone. Therefore, this change should be paired with appropriate authorization policies if you are trying to restrict creation capabilities entirely.
Another consideration involves breadcrumbs and navigation. When the create button is removed, Filament still includes a "Create" link in the breadcrumbs if the resource supports it. To fully remove any reference to creation, you may also need to adjust breadcrumb generation settings or ensure that no other parts of your layout reference the create action indirectly.
If you are using custom forms or extending the resource with additional panels, verify that no child resources or tabs are inadvertently enabling creation logic for the same entity. Filamentâs modular architecture means that a single resource can have multiple forms attached to different sections, and disabling one does not automatically disable others unless explicitly configured.
For teams managing large-scale installations, this level of customization is common when integrating Filament with existing legacy systems or third-party tools. In such cases, documenting these overrides in your internal wiki or using a centralized configuration file can help maintain consistency across projects.
While there are no built-in commands to globally disable creation for all resources, you can create a trait that applies this logic across multiple resources if needed:
trait NoCreateButton
{
public static function canCreate(): bool
{
return false;
}
}
Then apply it to your CustomerResource:
class CustomerResource extends Resource
{
use NoCreateButton;
}
This keeps your codebase DRY while maintaining clarity about intent. Always test these changes in a non-production environment first, as removing UI elements can impact user expectations and workflow efficiency unexpectedly.