Hello Guys
I wanted to create search event form on website front end, so my user can search events by entering two date (from and to).
I have created class called events which have fields (Title, StartDate, EndDate).
I already followed steps mention here but I am
not able to modified as per my requirement. Please help me to find out quick solution.
Thanks in advance.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hey VPull,
Here's a way to get you going..
public function yourfunction(){
$event = Event::get();
$startdate = "2016-02-15"; /** so this would be $data["StartDate"]; **/
$enddate = "2016-02-20"; /** this would be $data["EndDate"]; **/
$event = $event->where('("Event"."StartDate" >= \'' .date('Y-m-1', $startdate). '\' AND "Event"."EndDate" <= \'' .date('Y-m-t', $enddate). '\')');
return $event;
}
Thanks for you reply, but this code does not work with my requirement.
The easiest way often takes a long time to come up to.
Thank you for providing a code. I needed it.