atk4 / atk4

PHP framework for developing powerful web applications. Inspired by desktop toolkits (QT, Cocoa, .NET). For developers with any skill level.
http://agiletoolkit.org/
MIT License
182 stars 84 forks source link

DatePicker not working #715

Open romaninsh opened 8 years ago

romaninsh commented 8 years ago

Current develop branch fails to properly work with DatePicker. See error below:

BaseException: Date format is not correct

Additional information:

/Users/rw/Sites/medetourism/shared/lib/Form/Field.php:230 File Object Name Stack Trace Help /Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/Form/Field/DatePicker.php:98 3bb1d60dew_requested_dates_from Form_Field_DatePicker->exception("Date format is not correct")
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/Form/Field/DatePicker.php:61 3bb1d60d__ew_requested_dates_from Form_Field_DatePicker->convertDate(False, "Y-m-d", "Y-m-d") /Users/rw/Sites/medetourism/shared/lib/Form/Field.php:230 3bb1d60d
ew_requested_dates_from Form_Field_DatePicker->set("14-March-2016") /Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/AbstractObject.php:912 3bb1d60d__ew_requested_dates_from Form_Field_DatePicker->loadPOST(Object(Form_BidDetails))
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/Form/Basic.php:543 medetourism-front_layout_my_bid_form_biddetails Form_BidDetails->hook("loadPOST")
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/Form/Basic.php:621 medetourism-front_layout_my_bid_form_biddetails Form_BidDetails->submitted()
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/Form/Basic.php:629 medetourism-front_layout_my_bid_form_biddetails Form_BidDetails->isSubmitted()
/Users/rw/Sites/medetourism/frontend/lib/Form/BidDetails.php:181 medetourism-front_layout_my_bid_form_biddetails Form_BidDetails->onSubmit(Object(Closure))
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/AbstractObject.php:410 medetourism-front_layout_my_bid_form_biddetails Form_BidDetails->init() /Users/rw/Sites/medetourism/frontend/page/bid.php:90 medetourism-front_layout_my_bid page_bid->add("Form_BidDetails")
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/AbstractObject.php:410 medetourism-front_layout_my_bid page_bid->init()
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/App/Frontend.php:164 medetourism-front_layout_my Layout_My->add("page_bid", Array(1), "Content") /Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/App/Web.php:620 medetourism-front Frontend->layout_Content()
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/App/Frontend.php:48 medetourism-front Frontend->addLayout("Content")
/Users/rw/Sites/medetourism/vendor/atk4/atk4/lib/App/Web.php:379 medetourism-front Frontend->initLayout()
/Users/rw/Sites/medetourism/frontend/public/index.php:6

romaninsh commented 8 years ago

Attempted to fix in 8218496dcc61c587e6aa71f6a631c440367c19de, but didn't work.

romaninsh commented 8 years ago

Suggested solution for this problem is to make use of altField in datepicker fields.

http://api.jqueryui.com/datepicker/#option-altField

This way config file may contain:

$config['locale']['date_js'] = 'dd-MM-yy';

and the JS will still send us date in a consistent format, which we can parse correctly.

DarkSide666 commented 8 years ago

Can you please post here your config values, like:

$config['locale']['date'] = 'd.m.Y';
$config['locale']['time'] = 'H:i:s';
$config['locale']['datetime'] = 'd.m.Y H:i:s';
$config['locale']['date_js'] = 'dd.mm.yy';

Probably we should fix this by using altField (http://stackoverflow.com/questions/11522784/how-to-make-jqueryui-datepicker-submit-in-a-different-format-than-what-is-being/13958379#13958379). I have done that in my (unpublished) DateIntervalPicker add-on for 4.2.