datepicker filtering

How to fix date format issues in a ChronoForms datepicker filter.

Overview

The datepicker displays dates in m-d-Y format even when Y-m-d is specified in the data-gdatetimepicker-format attribute.
Add the data-format=Y-m-d attribute in the Extra fields element of the datepicker input to correctly apply the desired format.

Answered
ad admin_wiky 28 Apr, 2016
Hello there,
I need put datepicker for filtering fromDate and find out this topic

but I have a problem with date format. even though I have set format Y-m-d the date is displayed in the format m-d-Y - 28-04-2016
<input type="text" id="cf_creted" name="fltr[navstevy][datum]" data-gdatetimepicker-format="Y-m-d" placeholder="" size="9" class="form-control A" title="" style="display:inline;" data-load-state="" data-tooltip="" type="text" data-fieldtype="gdatetimepicker" data-start_view="d"  />

and I dont know where is the problem? is input name correct? Navstevy is model, datum is column
[attachment=0]ScreenShot938.jpg[/attachment]
<?php
  $document = \GCore\Libs\Document::getInstance();
  $document->_('jquery');
  $document->_('gdatetimepicker');
  $document->addJsCode('jQuery(document).ready(function($){
   $("#cf_creted").gdatetimepicker();
  });');
?>


thx for hint
Gr GreyHead 28 Apr, 2016
Hi homeopat,

Please post a link to the form so I can take a quick look.

Bob
Gr GreyHead 28 Apr, 2016
Answer
Hi Homeopat,

Sorry, I can’t spot the problem, the format is set correctly in the datepicker input. But when it is applied to the datepicker it is failing. You might try adding an attribute in the Extra fields element data-format=Y-m-d and see if that works.

It seems to work correctly in a ChronoForm so I guess that something in the CC setup is breaking it.

Bob
ad admin_wiky 29 Apr, 2016
Hi Bob,
thx, I added as a extra parameter and works.
but filtering doesnt works as is mentioned in previous article.
I want to use datepicker to filter data from the choosen date to today (now) but I am not sure, if the code is correct
thank you
This topic is locked and no more replies can be posted.