Ok here’s an annoying thing.
You are so used to using the DatePicker widget, but now you have a form with a lot of computation inside. So you decided to use Vue.js
<div id='app'> </div>
What do you do?
Here are the Steps to solve it
-
Install vue-bootstrap-datetimepicker
You can simply put this in the composer ‘required’ -
Install moment/moment
-
Wire them up by including the files with AppAsset
source = ‘@vendor/…path to file’
look for the moment.js and the datepicker.js
- Include the component in the Vue object
var app = new Vue({
el: '#app',
data: {
},
components: {
vuejsDatepicker
},
-
You will not be editing it, but rather copying the datepick to your activeform input using the :value => “dateF”
-
The datepicker sets the date in an annoying JS format, so you’ll need to apply a transformation to put it into the YYYY-MM-DD format that we love in MariaDB.
let date_ = new Date(this.from)
if(isNaN(date_.getTime())) {
console.log('invalid');
return '';
}
return moment(date_).format("YYYY-MM-DD")
Here I test if the date is valid, and then use moment.js to format it through a computed event.