0

I create a nova tool and need to have a datepicker.

In order to see the Nova datepicker, I did the following:
I added to User migration file:

$table->date('birthday')->nullable();

And reflected it in User.php and Nova\User.php:

public static $search = [
    'id', 'name', 'email', 'birthday'
];

public function fields(Request $request)
{
    return [
           :
           :
        Date::make('birthday')
            ->sortable(),

    ];
}

I got a nice datepicker: enter image description here

Now I would like to have the same in my tool, but cannot manage to attach it to the date field.

By-the-way, the date field in user form has the following html:

<input data-v-d0bd8056="" dusk="birthday" name="birthday"
       type="text" placeholder="2018-10-25" 
       class="w-full form-control form-input form-input-bordered flatpickr-input active">

Any help? Thanks!

guyaloni
  • 4,972
  • 5
  • 52
  • 92

1 Answers1

3

Ok, got it!

I found the flatpicker component page and followed the installation and usage instructions.

Then in order to have it nicely formed:

<flat-pickr v-model="fromDate" class="form-control form-input form-input-bordered datepicker-field"></flat-pickr>

And in <style> tag I added:

.datepicker-field {
    cursor: pointer !important;
    background-color: white !important;
}

Clean and easy!

guyaloni
  • 4,972
  • 5
  • 52
  • 92