In CakePHP, how do I create a form to list models withing a date range?
Posted
by anonymous coward
on Stack Overflow
See other posts from Stack Overflow
or by anonymous coward
Published on 2010-05-14T16:25:29Z
Indexed on
2010/05/14
16:44 UTC
Read the original article
Hit count: 183
I have a very simple model that includes the auto-filled field much like 'created'. (DateTime format).
I'd like to use the Form helpers if possible, to validate the date fields and whatnot.
I'd like a simple form with a "Begin Date" (YMD, 12 hours), and an "End Date" (same format).
There is already a controller action set up as follows:
function view_between($start_date = null, $end_date = null) {
// ... stuff that works correctly when the URL is manually entered.
}
Have I defined the controller wrong, or how can I pass these values into that function?
The reason I'm stuck is because I tried adding a $form->input('my_datetime_field' ...)
twice, but obviously the name/id were the same on the respective elements.
I have also tried using $form->dateTime(...)
with similar results.
I'm not sure how to uniquely identify a Begin and End date selection, when it should interact with a single field.
Am I going about this wrong? A kind shove in the right direction should suffice.
© Stack Overflow or respective owner