Rijak0 / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
0 stars 0 forks source link

Pre-filling Form Elements with date in the future #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Pre-Filling a $form->addDate with a Date in a future month
2. The Date is shown correctly
3. Click in the field to open the calendar

What is the expected output? What do you see instead?
I expect the month and day of the prefilled date
Instead the calendar is on the actual day / month

What version of the product are you using? On what operating system?
Current Version: 0.9.8
XP and Linux PHP 5

Original issue reported on code.google.com by bernhard...@gmail.com on 10 Feb 2010 at 3:03

GoogleCodeExporter commented 9 years ago
Hi bernhard,

Here is a quick solution to this, i didnt have time to try and do it correctly.

On line 2196 you can change it to:
                    $str .= "\n\t\t\t" . '$("#' . $jqueryDateIDArr[$d] . '").datepicker({
dateFormat: "yy-mm-dd", showButtonPanel: true, defaultDate:
$.datepicker.parseDate("yy-mm-dd", "' . $ele->attributes["value"] . '") });';

You can then set the value to your datepicker to something like:
            $form->addDate("Date:", "field0","2001-08-27");

There should probably be an attribute that lets you set the dateFormat, when i 
get a
bit more time i'll try to do it properly and we'll see if ajporterfield likes 
it :-P

Thanks,
moncojhr

Original comment by moncojhr@gmail.com on 12 Feb 2010 at 5:08

GoogleCodeExporter commented 9 years ago
Hey Guys,

If you have a date that is formatted YYYY-MM-DD, you will need to reformat 
using the
date/strtotime functions before passing it as a value to the addDate() method.  
Below
is an example.

$dateStr = "2010-02-12";
$dateStr = date("F j, Y", strtotime($dateStr));
$form->addDate("Date:", "myDateField", $dateStr);

- Andrew

Original comment by ajporterfield@gmail.com on 12 Feb 2010 at 2:25

GoogleCodeExporter commented 9 years ago

Original comment by ajporterfield@gmail.com on 14 Feb 2010 at 3:30