Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup format of datetime picker in easyadminbundle?

How can I change the default format used by the datetime picker of easyadminbundle?

I understand I must change something in config.yml in type_options of field property. Or setup some different datetime format. But how or where?

enter image description here

like image 763
Anton Smatanik Avatar asked Mar 27 '17 06:03

Anton Smatanik


2 Answers

easy_admin:
  design:
    assets:
        js: ['assets/js/jquery.datetimepicker.full.js(Your Date picker Js)', 'assets/js/initDatePicker.js (Your code to initialize date picker on base of class "datepicker")']
        css: ['assets/css/jquery.datetimepicker.css(Path of your datepicker css)']
  form:
     title: 'Your Title'
     fields:
        - { property: 'displayFrom', label: 'Display From', type_options: {'widget': 'single_text', 'format': 'dd/MM/yyyy H:mm', 'attr': {'class': 'datepicker'}} }

Just replace path of javascript and css and init datepicker, Also replace the field (displayFrom) with your form field.

like image 186
Maulik Savaliya Avatar answered Sep 29 '22 03:09

Maulik Savaliya


In yml you can use datepicker class like this.

form:
   title: 'Create User'
   fields:           
        - { other fileds ...}
        - { property: 'expiredAt', label: 'Credentials expired at', type_options: {'widget': 'single_text', 'format': 'dd/MM/yyyy H:mm', 'attr': {'class': 'datepicker'}} }

replace expiredAt with your field name. Hope this may helpful to you or anyone else.

like image 42
Maya Shah Avatar answered Sep 29 '22 04:09

Maya Shah