Hello all,
Posting in the correct thread this time. Sorry moderators!
I am trying to get to grips with Yii and am getting there, but I am struggling badly with date formats.
Basically, I have a MYSQL field that is a DATE type.
This is stored as YYYY-MM-DD.
I generated the model and the CRUD via Gii and have seen the date is a string input in the CRUD, and can see that the input and display of the date is almost a direct copy of the mySQL definition. ie YYYY-MM-DD
I found this great control, not allowed to post links on my first post, so if you go to demos.krajee.com/datecontrol
I have successfully installed using composer, and have managed to use in my application via the widget on my form and have managed to get the format to work directly on the widget.
But this is directly done by editing the _form.php of my CRUD.
The creator seems to imply on the link above that if I set the params of my application I can have have a default format for both viewing and saving to date fields across my whole app.
So I thought I would tackle view first and in my application (which is a copy of the advanced Yii application) I went to common/config/params.php
I then put in the following code:
<?php
use kartik\datecontrol\Module;
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'user.passwordResetTokenExpire' => 3600,
'dateControlDisplay' => [
Module::FORMAT_DATE => 'dd/MM/yyyy',
Module::FORMAT_TIME => 'HH:mm:ss a',
Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss a',
],
];
However my date format for my date field still remains like this 2015-02-01 not dd/MM/yyyy as I had hoped.
I have asked the creator for help, but he tells me I need to review his documentation and refer to the Yii documentation on setting parameters. I have done this, but I am clearly missing something. I feel like I am drowning a bit in information and am a bit lost, so any help from anyone here would be gratefully received by a noob.
I promise I have been trying to figure this out for myself, but have spent hours for what must seem like a really simple thing to the rest of you clever people.
Thanks,
Mark
EDIT: if anyone wants to see the source code I have, just let me know and I can get you read only access to the git library, I have set up a test rig that just has the advanced app and this functionality poorly added to it.