F
Filamentβ€’4mo ago
Benjamin

Trying to make a custom field (for custom complex component)

Hi guys! I'm trying to make a custom field component for an edit resource page form. Here is what I writed, to test the property reactivity, but it doesn't work.
// MissionSchedule.php
namespace App\Filament\Forms\Components;
use Filament\Forms\Components\Field;

class MissionSchedule extends Field
{
public $hasMonday = 'Sample text';
protected string $view = 'filament.forms.components.mission-schedule';
}
// MissionSchedule.php
namespace App\Filament\Forms\Components;
use Filament\Forms\Components\Field;

class MissionSchedule extends Field
{
public $hasMonday = 'Sample text';
protected string $view = 'filament.forms.components.mission-schedule';
}
// mission-schedule.blade.php
<div>
<x-filament::input.wrapper>
<x-filament::input type="text" wire:model.live="hasMonday" />
</x-filament::input.wrapper>
<span wire:model.live="hasMonday"></span>
</div>
// mission-schedule.blade.php
<div>
<x-filament::input.wrapper>
<x-filament::input type="text" wire:model.live="hasMonday" />
</x-filament::input.wrapper>
<span wire:model.live="hasMonday"></span>
</div>
// MissionResource.php in form() method :
MissionSchedule::make('schedule')
->label(__('Schedule'))
->helperText(__('Will be used to automatically generate the hours.'))
->live()
->hidden(fn (\Filament\Forms\Get $get): bool => $get('mission_type') !== MissionTypeEnum::FIXED_SCHEDULE->value),
// MissionResource.php in form() method :
MissionSchedule::make('schedule')
->label(__('Schedule'))
->helperText(__('Will be used to automatically generate the hours.'))
->live()
->hidden(fn (\Filament\Forms\Get $get): bool => $get('mission_type') !== MissionTypeEnum::FIXED_SCHEDULE->value),
Why I don't see "Sample text" in my field ?
No description
2 Replies
Benjamin
Benjaminβ€’4mo ago
To be more clear : I need to create a custom field that show a button. When we click on thsi button, it should open a modal with a custom form to select multiple things. Those things will be stored as JSON (this is a schedule) :
No description
gladjanus43
gladjanus43β€’4mo ago
If it is a button, what do you need the input for? If the form opens a new modal with a form? Just to get your question straight πŸ™‚ because if it is just a button, you could add an action to that button which opens the modal with the form!
Want results from more Discord servers?
Add your server
More Posts