1. Go to this page and download the library: Download coolsam/flatpickr library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coolsam / flatpickr example snippets
use Coolsam\FilamentFlatpickr\Forms\Components\Flatpickr;
// Basic, Date Field
Flatpickr::make('test_field') // Minimal Config as a datepicker
Flatpickr::make('test_field')
->allowInput() // Allow a user to manually input the date in the textbox (make the textbox editable)
->altInput(true) // Enable the use of Alternative Input (See Flatpickr docs)
->altFormat('F j, Y') // Alternative input format
->time(true) // Turn this into a DateTimePicker
->disabledDates(['2023-07-25','2023-07-26']) // Disable specific dates from being selected.
->minDate(fn() => today()->startOfYear()) // Set the minimum allowed date
->maxDate(fn() => today()) // Set the maximum allowed date.
->hourIncrement(1) // Intervals of incrementing hours in a time picker
->minuteIncrement(10) // Intervals of minute increment in a time picker
->seconds(false) // Enable seconds in a time picker
->defaultSeconds(0) //Initial value of the seconds element, when no date is selected
->defaultMinute(0) // Initial value of the minutes element, when no date is selected
->allowInvalidPreload() // Initially check if the selected date is valid
->altInputClass('sample-class') // Add a css class for the alt input format
->format('Y-m-d') // Set the main date format
->ariaDateFormat('Y-m-d') // Aria
->clickOpens(true) // Open the datepicker when the input is clicked.
->closeOnSelect(true) // Close the datepicker once the date is selected.
->conjunction(',') // Applicable only for the MultiDatePicker: Separate inputs using this conjunction. The package will use this conjunction to explode the inputs to an array.
->inline(true) // Display the datepicker inline with the input, instead of using a popover.
->disableMobile(true) // Disable mobile-version of the datepicker on mobile devices.
->mode(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMode::RANGE) // Set the mode as single, range or multiple. Alternatively, you can just use ->range() or ->multiple()
->monthSelectorType(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMonthSelectorType::DROPDOWN)
->shorthandCurrentMonth(true)
->noCalendar(true) // use this in conjunction with `time()` to have a timePicker
->position(\Coolsam\FilamentFlatpickr\Enums\FlatpickrPosition::AUTO_CENTER)
->showMonths(1)
->weekNumbers(true)
->time24hr(true)
->timePicker() // Configure a timepicker out of the box
->weekPicker() // configure a week picker out of the box
->monthPicker() // configure a month picker out of the box
->rangePicker() // configure a date range picker out of the box
->multiplePicker() // Configure a multiple date picker out of the box
;
// You can also use the component as a DateTimePicker, Range Picker, Week Picker, Month Picker, TimePicker and Multiple Date Picker
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('start_time')->timePicker(),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('week_number')->weekPicker()->format('W Y'),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('month')->monthPicker()->format('Y-m')->displayFormat('F Y'),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('range')->rangePicker(),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('occupied_slots')->multiplePicker()->format('Y-m-d')->displayFormat('F j, Y'),
use Coolsam\FilamentFlatpickr\Enums\FlatpickrTheme;
return [
'theme' => FlatpickrTheme::AIRBNB,
];
bash
php artisan flatpickr:install
bash
php artisan filament:upgrade
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.