Date Field in Custom Block
Permalink
Is it possible to create a "Date Field" in a custom block?
I am creating a site for a musician with a page showing tour dates. I'm hoping to just have a date-picker that they can use to select a date for their tours.
I am creating a site for a musician with a page showing tour dates. I'm hoping to just have a date-picker that they can use to select a date for their tours.
Have you thought about a pre-made solution:http://www.concrete5.org/marketplace/addons/dojo-tour-dates/... ?
I already have my block setup and working... the linked block still doesn't resolve my issue as it looks like the user would still have to manually type in the date in an input field.
I would like to just have a date selector that populates that field.
I would like to just have a date selector that populates that field.
Yes. Check out the date/time form helper:
http://www.concrete5.org/documentation/developers/forms/concrete5-w...
http://www.concrete5.org/documentation/developers/forms/concrete5-w...
Cool. That's exactly what I needed. I am having some issue with the "$dtt->translate" function to post the value into the database. I'm pretty sure I'm not using it correctly, as I get an error... but, I know I need to implement it somehow in order to format it correctly.
This is what I have so far:
Thanks for the help!
This is what I have so far:
Thanks for the help!
Another solution would be to use use jquery's datepicker (http://jqueryui.com/demos/datepicker/)?
i don't think it's included in the jquery ui files in the C5 core so gohttp://jqueryui.com/download uncheck everything possible and only leave datepicker, widget, core and ui, then include them in your header..
then use
and you should be good to go. seehttp://docs.jquery.com/UI/Datepicker/formatDate... for available formats.
i don't think it's included in the jquery ui files in the C5 core so gohttp://jqueryui.com/download uncheck everything possible and only leave datepicker, widget, core and ui, then include them in your header..
then use
$('#tour_date').datepicker(dateFormat: 'yy-mm-dd');
and you should be good to go. seehttp://docs.jquery.com/UI/Datepicker/formatDate... for available formats.
As of 5.4 datepicker is included in the core jquery.ui.js. All the files to run it should also be loaded when a page is in edit mode.
And translate() isn't used in the front-end. All you should have to use is the DateHelper::date() or DateHelper::datetime() methods. The translate() method is for taking a post and translating it back into a date string.
And translate() isn't used in the front-end. All you should have to use is the DateHelper::date() or DateHelper::datetime() methods. The translate() method is for taking a post and translating it back into a date string.
good to know that it's included!
Has anyone used jQuery date picker? I thought it made use of jQuery's dialog, so I wonder about any conflicts with C5's dialog.
-Steve
-Steve
pretty sure it doesn't. i think i've only used it in the dashboard and that worked fine, so the same should go for the front-end.
Still using the form helper (I got rid of the 'translate')...
When I submit the form, the database field always ends up as "0000-00-00 00:00:00 ", so something isn't being formatted correctly as a date when it's sent.
When I submit the form, the database field always ends up as "0000-00-00 00:00:00 ", so something isn't being formatted correctly as a date when it's sent.
I ended up switching the database field type to VARCHAR instead of a DATE and it worked fine.