Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #5797
      zhangqi
      Member

      Piklist is very useful for me, but I dont know how to use datetime in piklist? for exsample:2016-01-29 01:38
      thank you!

    • #5809
      jivedig
      Member

      I couldn’t get it to work either. I ended up using a text field with a wrapper class (attribute) on the field, and used https://github.com/xdan/datetimepicker with a target of that field element. Working well so far.

      Attachments:
      You must be logged in to view attached files.
    • #7651
      Stephen
      Participant

      Anyone have any code examples for how to implement this? Thanks in advance

    • #7652
      Stephen
      Participant

      Nevermind I figured it out. Here is the code if it helps someone:

      In my setup plugin:

      // DATETIMEPICKER ENQUEUE
      
      add_filter('piklist_assets', 'my_assets');
      
      function my_assets($assets)
      {
        array_push($assets['scripts'], array(
          'handle' => 'datetimepicker'
          ,'src' => get_template_directory_uri() . '/js/jquery.datetimepicker.full.js'
          ,'ver' => '2.5.4'
          ,'deps' => 'jquery'
          ,'enqueue' => true
          ,'in_footer' => true
          ,'admin' => true
          ,'front' => false
        ));
      
       array_push($assets['scripts'], array(
          'handle' => 'dtpickermine'
          ,'src' => get_template_directory_uri() . '/js/dtpickermine.js' //my jQuery(document).ready code...
          ,'ver' => '1.0'
          ,'deps' => 'jquery'
          ,'enqueue' => true
          ,'in_footer' => true
          ,'admin' => true
          ,'front' => false
        ));
      
        array_push($assets['styles'], array(
          'handle' => 'datetimepickerclasses'
          ,'src' => get_template_directory_uri() . '/js/jquery.datetimepicker.css'
          ,'ver' => '1.2'
          ,'enqueue' => true
          ,'in_footer' => true
          ,'admin' => true
          ,'media' => 'screen, projection'
        ));
        
        return $assets;
      }  

      And then in my meta field definition:

      piklist('field', array(
       'type' => 'text'
         ,'field' => 'ae_dtpicker'
         ,'label' => __('my date time', 'direct-action')
          ,'attributes' => array(
            'class' => 'dtpicker'
          )
        ));    
Viewing 3 reply threads
  • The topic ‘how to use datetime in piklist?’ is closed to new replies.