skashizadeh
Accessing a form component from another
TRY THIS
[
Forms\Components\Select::make('type_event_id')
->label(('labels.type'))
->required()
->reactive()
->prefixIcon(fn (?string $state) => !is_null($state)
? 'heroicon-m-stop'
: null
)
->afterStateUpdated(function ($state, $set, $get) {
// Trigger a re-render
$set('title', $get('title') . '');
$set('titlePlaceholder', "$state");
})
->prefixIconColor(function (Forms\Components\Select $component) {
$color = $component->getSelectedRecord()?->background_color;
return !is_null($color) ? Color::hex($color) : null;
})
->relationship(
'typeEvent',
'name'
)
->createOptionForm(TypeEventResource::formSchema())
->createOptionAction(
fn (Forms\Components\Actions\Action $action) => $action
->slideOver()
->modalWidth('xl'),
),
Forms\Components\TextInput::make('title')
->label(('labels.title'))
->placeholder(fn ($get) => $get('titlePlaceholder') ?? 'Default placeholder')
->reactive(),
]
24 replies
Eager loaded relationships filter
this might help
```
->filters([
Filter::make('posts_between_dates')
->form([
DatePicker::make('start_date')
->label('Start Date')
->required(),
DatePicker::make('end_date')
->label('End Date')
->required(),
])
->query(function ($query, array $data) {
$startDate = Carbon::parse($data['start_date'])->startOfDay();
$endDate = Carbon::parse($data['end_date'])->endOfDay();
return $query->whereHas('posts', function ($q) use ($startDate, $endDate) {
$q->whereBetween('created_at', [$startDate, $endDate]);
});
}),
]);
14 replies
DatePicker type moth not working in Firefox and Safari
as you can see in here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month#browser_compatibility firefox / safari does not support type month. so i think you can use jquery or use two different select field ( one for month and the other for year )
3 replies