TypeError: $.fn.datetimepicker.dates is undefined format: "dd/mm/yyyy"
TypeError: $.fn.datetimepicker.dates is undefined format: "dd/mm/yyyy"
Hi Allen.
I figure out the style sheet issue by adding bootstrap.css and bootstrap.js about previous question :
https://datatables.net/forums/discussion/comment/69152#Comment_69152
but some datatime picker icon gone. any idea ? I will keep checking whether I miss any file anyway.
But I got new error with format:
TypeError: $.fn.datetimepicker.dates is undefined
format: "dd/mm/yyyy"
my html code is:
{
"label": "Message create time",
"name": "time_add",
"type": "datetime",
}
my php code is:
Field::inst( 'time_add' )
->validator( 'Validate::dateFormat', array( 'empty'=>false, 'format'=>'M/d/Y H:i A' ) )
->getFormatter( 'Format::date_sql_to_format', 'd-M-Y H:i A' )
->setFormatter( 'Format::date_format_to_sql', 'M/d/Y H:i A' )
the expected text on datatime picker is like: 12/01/2014 11:30 AM
any suggestions?
Thank you very much
Answers
I found another issue
in my datatables , there are two data type with two datatime picker
the first one is working, but for the second one, I can not get data on server end.
how to modify the plugin code to make it work?
Thanks
Hi,
Could we possibly continue this discussion in a single thread please? Hadn't realised that you'd already resolved the Bootstrap issue before replying to your previous thread. Thanks!
It looks like there is an error in the plug-in where it doesn't actually specify what icon should be shown! Where it has:
Can you replace it with:
I'll update the site tomorrow morning.
I've just tried the URL you PM'ed me, but the server doesn't appear to be responding at the moment. I'll try again later on.
Regards,
Allan
Hi Allen
Sorry about multiple thread.
I have solved icon miss issue by adding bootstrap font js css file , you may need mention these on bootstrap plugin document page as well:)
the "TypeError: $.fn.datetimepicker.dates is undefined" seems that come from format function.
After I change my php code to
it works
But, for datetime picker, your validator function is not that quite right working
if I code like this
it shows format doesn't match, but I check the http request , the format should be right, which means your validator function may not go through formate with min sec?
I also try to customize validator code as below for testing
it works in some case.
But I found a bug with two datetime picker on one table.
Because datetime picker will auto fill up the text input, even you delete the text( leave it blank)( which is kind of no empty validation? I don know, but it helps)
But if you delete one datetime picker text input(or try random funny input) , then delete (or try random funny input) for the second datetime picker, (When you input on the second one, the first datetime picker will auto fill the date back, it is fine, but......)
the firebug will pop out "TypeError: conf._input.data(...).getDate(...) is null"
and page is not working anymore.
For testing this bug, you can try the html page I send you before. ( I will delete that page in couple days later, this bug is there , but not that important for us)
One more question
If I have two database , how to set up the config.php fire?or I can create two editor files with different name under Datatables extensions directory ?
Hi,
It should do - however, I've just tried the page you sent me before, at it looks like the data for the date/time is being sent in a full Javascript format. For example:
This is a function of moment.js's
toString()
method - it returns that format unless otherwise specified. You could modify the plug-in code to replace.toString()
with.format(...)
- or possibly update the PHP to validate the moment.js returned string. Possibly I should update the plug-in so it returns an ISO format which might be a bit more useful than the JS format. Your thoughts are welcome!Thanks for letting me know about that. I'll take a look into it and try to see what the problem is.
The
DataTables.php
file will automatically create a database connection based on the options inconfig.php
. However, you can also use theDatabase
class to create another database connection, in exactly the same wayDataTables.php
does, if you need. The documentation for that class is available here.Regards,
Allan
Update on the date / time picker. I've just made a change to the plug-in which will cause it to submit the value from the text box, rather than the Moment.js defined value (it was submitting a Javascript date / time string which wasn't much use...).
Updated plug-in is available here: http://editor.datatables.net/plug-ins/field-type/editor.datetimepicker-2
Regards,
Allan