# |
Apr 19th 2019, 18:43 |
ricksaccous |
@swimboy https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data |
# |
Apr 19th 2019, 18:42 |
ricksaccous |
hmmmm |
# |
Apr 19th 2019, 18:42 |
ricksaccous |
so DateTimeType->setLocaleFormat('') and then you can set the format |
# |
Apr 19th 2019, 18:42 |
ricksaccous |
I think in bootstrap or Application.php or something you can setLocaleFormat() |
# |
Apr 19th 2019, 18:41 |
ricksaccous |
if you look at DateTimeType.php |
# |
Apr 19th 2019, 18:41 |
ricksaccous |
i seeeee |
# |
Apr 19th 2019, 18:40 |
swimboy |
Yeah, that gets us right back where we started. The JS is returning it in one format, but CakePHP wants another format. I'm trying to find a way that I can display an input all my dates in m/d/Y format, but have the data saved to the database as Y-m-d. |
# |
Apr 19th 2019, 18:39 |
ricksaccous |
'Y-m-d' |
# |
Apr 19th 2019, 18:38 |
ricksaccous |
i think the format it wants is |
# |
Apr 19th 2019, 18:38 |
ricksaccous |
heheeh |
# |
Apr 19th 2019, 18:38 |
swimboy |
Yeah, that's what it looks like. If I use the standard date picker, it returns an object with year, month, and day values. When I use the JS, it returns the string "4/17/2019". |
# |
Apr 19th 2019, 18:37 |
ricksaccous |
i think cake MIGHT expect a certain format for date in request data to format it into FrozenDate, hmph |
# |
Apr 19th 2019, 18:33 |
swimboy |
Yes, it is. I'm digging into the code, and there's some JS that's generating a pop-up calendar to enter the date. It must be causing a problem with CakePHP being able to parse the input as a date when it's returned. |
# |
Apr 19th 2019, 18:29 |
ricksaccous |
is it a date field in the schema? |
# |
Apr 19th 2019, 18:29 |
ricksaccous |
@swimboy that doesn't sound right at all, it should be just changing it based on it's type |
# |
Apr 19th 2019, 18:13 |
swimboy |
In the request data, it's '4/17/2019' |
# |
Apr 19th 2019, 18:12 |
waspinator |
`$this->request->getQuery('redirect', ['default'])` always returns default |
# |
Apr 19th 2019, 18:12 |
swimboy |
Actually, after patchEntity, the date field is null. |
# |
Apr 19th 2019, 18:08 |
waspinator |
@admad okay, so how would I get the requesting page? I think it used to be in `$this->Auth->redirect()` |
# |
Apr 19th 2019, 18:05 |
swimboy |
frozendate |
# |
Apr 19th 2019, 18:03 |
ricksaccous |
@swimboy after you patchEntity is the date field a frozentime or frozendate object? |
# |
Apr 19th 2019, 18:02 |
swimboy |
@ricksaccous I am calling patchEntity but it was still trying to stuff "4/19/2019" into the date field in my MariaDB table and spitting out SQL errors. |
# |
Apr 19th 2019, 18:01 |
admad |
No it doesn't, home page is just the default value |
# |
Apr 19th 2019, 17:48 |
waspinator |
how would you redirect to the requesting page after logging in using the Authentication plugin? The [example](https://github.com/cakephp/authentication/blob/master/docs/en/migration-from-the-authcomponent.rst#login-action) always redirects to the pages home display |
# |
Apr 19th 2019, 17:47 |
ricksaccous |
as far as displaying dates that's completely up to you to use the Cake Libs available to you |
# |
Apr 19th 2019, 17:46 |
ricksaccous |
done |
# |
Apr 19th 2019, 17:46 |
ricksaccous |
third step - save |
# |
Apr 19th 2019, 17:46 |
ricksaccous |
second step - patch entity, your request data becomes a frozenDate object |
# |
Apr 19th 2019, 17:46 |
ricksaccous |
so first step - request data |
# |
Apr 19th 2019, 17:45 |
ricksaccous |
you can safely save a FrozenTime object and cake will translate it however it needs to |
# |
Apr 19th 2019, 17:45 |
ricksaccous |
@swimboy generally when you save dates and you patchEntity cake will transform the date into a FrozenTime object |
# |
Apr 19th 2019, 17:37 |
swimboy |
Couldn't quite figure it out, though. |
# |
Apr 19th 2019, 17:37 |
swimboy |
OK. I just saw the `Time::niceFormat` section in the book, and thought maybe that would help make things more straightforward. |
# |
Apr 19th 2019, 17:36 |
NickBusey |
Sounds about right to me |
# |
Apr 19th 2019, 17:35 |
slackebot |
right way to do it. Any suggestions? |
# |
Apr 19th 2019, 17:35 |
swimboy |
I'm a little lost regarding displaying dates and storing them in my database. I want to display them (and have the user enter them) as "04/19/2017" but the database wants them stored as "2017-04-19." I've originally set `Cake\I18n\Date::setToStringFormat('yyyy-MM-dd');` in my bootstrap, and then use a function to convert any date field in POST requests to the SQL format before saving the record. It works, but it sure doesn't feel like the |
# |
Apr 19th 2019, 11:55 |
admad |
the autocomplete is contextual and it will list only methods of current class, so it's not like you are going to get multiple "create" in the list |
# |
Apr 19th 2019, 11:53 |
mehov |
I thought having a noun first would kind of help when you're looking up that function in the list (so it'd all get sorted by it), but I guess that's not important |
# |
Apr 19th 2019, 11:52 |
admad |
no need for "createAccount() |
# |
Apr 19th 2019, 11:51 |
admad |
I would actually drop the noun too. Cause for eg. $this->Accounts->create() is good enough |
# |
Apr 19th 2019, 11:51 |
mehov |
Got it, thanks a lot! |