codewithdennis/filament-advanced-choice
Adds 8 advanced Filament form fields: radio- and checkbox-based card/stacked card variants plus enhanced CheckboxList with descriptions and extras. Supports Filament v4/v5 and integrates into custom themes via @source for proper styling.
Installation:
composer require codewithdennis/filament-advanced-choice
Add the CSS source to your Filament theme:
@source '../../../../vendor/codewithdennis/filament-advanced-choice/resources/**/*.blade.php';
Rebuild assets:
npm run build
First Use Case:
Replace a basic Radio or CheckboxList in a Filament form with a visually enhanced alternative. For example:
use CodeWithDennis\FilamentAdvancedChoice\Filament\Forms\Components\RadioCard;
RadioCard::make('plan')
->options([
'basic' => 'Basic Plan',
'pro' => 'Pro Plan',
]);
RadioCard) over plural aliases (e.g., RadioCards).Replacing Basic Fields:
Swap out Filament’s default Radio or CheckboxList for advanced variants (e.g., RadioCard for a card-based layout with descriptions and extras).
// Before
Radio::make('status')->options([
'active' => 'Active',
'inactive' => 'Inactive',
]);
// After
RadioCard::make('status')
->options([
'active' => 'Active',
'inactive' => 'Inactive',
])
->descriptions([
'active' => 'User is active and logged in',
'inactive' => 'User has not logged in recently',
]);
Searchable and Bulk-Actionable Lists:
Use searchable() and bulkToggleable() for checkbox-based fields to improve usability in forms with many options.
CheckboxList::make('tags')
->options(['php', 'laravel', 'filament', 'vue'])
->searchable()
->bulkToggleable();
Enum Integration:
Leverage enums for type safety and reusable option definitions. Implement HasLabel, HasDescription, and HasExtra interfaces.
enum UserRoleEnum: string implements HasLabel, HasDescription, HasExtra
{
case Admin;
case Editor;
case Viewer;
public function getLabel(): string { return match($this) { ... }; }
public function getDescription(): string { return match($this) { ... }; }
public function getExtra(): ?string { return match($this) { ... }; }
}
// In form
RadioStackedCard::make('role')
->options(UserRoleEnum::class);
Conditional Logic:
Disable options dynamically using disableOptionWhen().
CheckboxCard::make('permissions')
->options(PermissionEnum::class)
->disableOptionWhen(fn (string $value) => auth()->user()->cannot("manage_{$value}"));
Custom Styling: Apply colors or hide native inputs for a cleaner UI.
RadioCard::make('priority')
->options(PriorityEnum::class)
->color(Color::Red)
->hiddenInputs();
required, min_items) alongside the advanced fields.CSS Theme Dependency:
npm run build after installation.@source directive is in your Filament theme file (e.g., resources/css/filament/app.css).Deprecated Aliases:
RadioCards) may trigger deprecation warnings or break in future updates.RadioCard).Enum Implementation:
HasExtra interface on enums will ignore the extras() method in card-based fields.HasExtra:
enum DeliveryTypeEnum implements HasExtra { ... }
Hidden Inputs:
hiddenInputs() removes native browser controls, which may affect accessibility or keyboard navigation.visibleInputs() to revert or ensure ARIA attributes are manually added if hiding inputs.Repeater Fields:
Cursor Styles:
not-allowed cursor by default (added in v2.0.1). Overriding this requires cursorPointer().cursorPointer() to restore default hover behavior:
CheckboxList::make('options')->cursorPointer();
Styling Issues:
@source directive is correct and assets are rebuilt.Enum Not Rendering:
HasLabel, HasDescription, HasExtra for card fields). Use dd() to inspect the enum methods:
dd(DeliveryTypeEnum::Standard->getLabel());
Bulk Actions Not Working:
CheckboxList, CheckboxCard) and bulkToggleable() is called. Radio fields don’t support bulk actions.Search Not Triggering:
searchable() is called and the field has at least 3 options to avoid UI glitches. Check for JavaScript errors in the console.Custom Field Colors:
Extend the Color class or use existing presets (Color::Red, Color::Blue, etc.) for theming.
Hidden Input Icons:
Override the default heroicon-s-check-circle icon for hidden inputs:
RadioCard::make('field')->hiddenInputIcon('heroicon-o-x-circle');
Dynamic Options: Use closures or methods to fetch options dynamically (e.g., from a database):
CheckboxList::make('categories')
->options(fn () => Category::all()->pluck('name', 'id'));
Custom Layouts:
Extend the package’s Blade components to create custom layouts (e.g., grid-based cards). Study the existing components in resources/views.
Accessibility: Add custom ARIA attributes or labels to improve accessibility for screen readers:
RadioCard::make('field')->extraAttributes(['aria-describedby' => 'field-description']);
How can I help you explore Laravel packages today?