PDA

View Full Version : Date Picker on its own?


Andrew Read
01-21-2010, 05:49 PM
I know that this has been asked before, and from what I understand, the "DatePicker" can not be used on its own (without a "CSS Form Builder" form.)

How hard would it be to create this as a behaviour that could be separately added to any date field? If none of your users have officially requested it, then I will.

It would be nice to use this with a DataAssist form as well, without the need for CSS FB (which seems to be breaking my DataAssist forms right now.)

Thanks,

Jason Byrnes
01-22-2010, 10:41 AM
I am moving this to the Wish List forum so our engineers will see your request, I am also logging a feature request.

Andrew Read
01-22-2010, 10:47 AM
Thanks for moving this.. I have noted the new location and will put all future feature requests here.

I actually decided to try and get datePicker to work on it's own last night. I built a fake form with the 4 date fields that I require, all setup as they are in the regular DataAssist form and used CSS Form builder on them making them all date pickers.

I then moved the required javaScripts and "datePicker" related includes into the DataAssist form. Everything seems to work -EXCEPT- that the dates are formatted incorrectly when they are put into the fields by datePicker (they are MM/DD/YYYY rather than the YYYY-MM-DD that MySql expects.)

What is required for these dates to be properly formatted before they are submitted by the query?

Thanks,

Andrew

Jason Byrnes
01-22-2010, 01:43 PM
The date picker elements are Spry Text Fields, the format used is controlled by Spry. To edit the format, select the Date picker filed, you will see a blue bounding box appear around the text field, click this to trigger the Properties inspector to show the Spry Options, Change the format option to the one you wish to use.

Andrew Read
02-19-2010, 10:42 AM
This will allow me to change the Spry Validation used, but does not allow me to change the format that the date picker is putting into the field.

I need to change the format that the date picker is dropping into the field from MM/DD/YYYY to YYYY-MM-DD so that is submits a valid date to the MySQL database.

How is this done?

Jason Byrnes
02-19-2010, 12:19 PM
In the insert record behavior, you can modify the binding to reformat the date as it is going into the database.



When you bind a column to a form field it will create code similar to:
<?php echo((isset($_POST["date"]))?$_POST["date"]:"") ?>


you can change that to use the date function to reformat the date:
<?php echo((isset($_POST["date"]))?date("Y-m-d", strtotime($_POST["date"]):"") ?>

Andrew Read
02-19-2010, 01:50 PM
Thanks Jason,

Looks like that would work, but in a post about displaying "UK dates" I discovered that you can just enter the correct date into the field in the first place by adding -- dateFormat: 'yy-mm-dd', -- after the -- changeYear: true -- line:


changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd',


It is possible that a combination of this and your rewrite would solve the UK date problem in that post.. might want to take a look a that post and see if they ever solved the issue.

It would probably be a good idea if the DataAssist just made any date fields format themselves properly automatically, so that he users don't have to go in and edit the code. Would it not?

Thanks,