Replies: 3 comments 3 replies
-
I don't think our date picker supports such a feature. The |
Beta Was this translation helpful? Give feedback.
-
I made some changes to my code. It only works for the current year. I couldn't figure out how to use reactive() function on year change. If someone can help me will be grateful that should solve my problem. public static function weekend($state, $week_days)
: array
{
$dateDay = ($state === null)
? \Carbon\Carbon::now()
: Carbon::parse($state);
$year = $dateDay->year;
$next_year = $year + 1;
$month = $dateDay->month;
$days = $dateDay->daysInMonth;
$arr = [];
foreach ($week_days as $week_day)
{
$days = new \DatePeriod(
Carbon::parse("first $week_day of $year"),
CarbonInterval::week(),
Carbon::parse("last $week_day of january $next_year")
);
foreach ($days as $day)
{
array_push($arr, Carbon::parse($day)->format('Y-m-d'));
}
}
return $arr;
}
DatePicker::make('issue_start_date')->dispatchEvent('weekend')
->required()
->reactive()
->closeOnDateSelection()
->weekStartsOnSunday()
->afterStateUpdated(function (callable $set, $state)
{
$month = date('M', strtotime($state));
$year = date('Y', strtotime($state));
($month == null || $year === null)
? $set('name', null)
: $set('name', $month . ' ' . $year);
})
->dehydrateStateUsing(function (callable $set, $state)
{
if ($state === null) $set('name', null);
})
->disabledDates(fn($state) => self::weekend(state: $state, week_days: ['saturday', 'friday'])), |
Beta Was this translation helpful? Give feedback.
-
I use Coolsam Flatpickr, because i want to show three months at once. It works fine, but the week starts on sunday. How can I set monday as start of week? |
Beta Was this translation helpful? Give feedback.
-
My form has DatePicker and I'm unable to disable all Weekends days or enable only multiple ranges of dates leaving other dates disabled
Here is my code
Beta Was this translation helpful? Give feedback.
All reactions