Tagged: 

Viewing 7 reply threads
  • Author
    Posts
    • #5481
      vayu
      Member

      Hi.
      I have a datepicker field. When I create a new post, the default value is 01. January, 1970. I need for it to be empty, also when I save the post. I tried to add this to the field options:

      'options' => array(
      	'dateFormat' => 'd-m-yy',
      	'setDate' => null
      )

      and value to empty. Is there something else I could do to have an empty value in the datepicker field?

    • #5487
      Steve
      Keymaster

      have you tried:

      'value' => null
      

      This does not go in the options array.

    • #5488
      vayu
      Member

      Thanks Steve, but I had already tried this.

      This is my code:

      piklist( 'field', array(
      	'type' => 'datepicker',
      	'scope' => 'post_meta',
      	'field' => 'invoice_approved_date',
      	'value' => null,
      	'label' => 'Dato godkendt',
      	'attributes' => array(
      		'class' => 'select invoice-approved-date',
      		'placeholder' => 'Dato godkendt',
      	),
      	'options' => array(
      		'dateFormat' => 'd-m-yy',
      		'firstDay' => 1,
      		'closeText' => 'Luk',
      		'prevText' => 'Forrige',
      		'nextText' => 'Næste',
      		'monthNames' => ['Januar','Februar','Marts','April','Maj','Juni','Juli','August','September','Oktober','November','December'],
      		'monthNamesShort' => ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
      		'dayNames' => ['Søndag','Mandag','Tirsdag','Onsdag','Torsdag','Fredag','Lørdag'],
      		'dayNamesShort' => ['Søn','Man','Tir','Ons','Tor','Fre','Lør'],
      		'dayNamesMin' => ['Sø','Ma','Ti','On','To','Fr','Lø'],
      		'weekHeader' => 'Uge',
      		'isRTL' => false,
      		'showMonthAfterYear' => false,
      		'yearSuffix' => ''
      	)
      ) );
    • #5491
      Steve
      Keymaster

      Your code is working for me with Piklist v0.9.9.7.

    • #5494
      vayu
      Member

      Okay, thanks for checking. I have the same piklist version, but it’s not working for me.

    • #5499
      Steve
      Keymaster

      @vayu– What happens if you set the value to a date, like today?

      'value' => date('M d, Y', time() + 604800)
      
    • #5504
      vayu
      Member

      Thanks again for helping me out! I found the cause for my problem, and it’s because I had added this code:
      https://piklist.com/support/topic/advice-for-sorting-by-date-with-date-picker/#post-4640, which by default does not let me use an empty value.
      I do apologise for having wasted your time, but your help got me on the right track.
      Thanks again!

    • #5507
      Steve
      Keymaster

      My pleasure!

      Glad it’s working fine.

Viewing 7 reply threads
  • The topic ‘datepicker field has default 01. January, 1970’ is closed to new replies.