I have a form on my homepage which i initiate with:
function DealSearchForm() {
$regions = DataObject::get("RegionPage");
$fields = new FieldSet(
new DropdownField('Region', 'Specify Region', $regions->map("ID", "Title", "Any")),
new DropdownField('Resort', 'Specify Resort', array(''=>'Any'))
);
// Create actions
$actions = new FieldSet(
new FormAction('doDealSearch', 'Search')
);
return new Form($this, 'DealSearchForm', $fields, $actions);
}
The regions and resorts are populated with javascript via the following jSON
function getRegionsJson(){
$regionsArray = array();
$regions = DataObject::get("RegionPage");
foreach($regions as $region) {
$regionsArray[$region->ID] = array();
foreach($region->Children() as $resort) {
$regionsArray[$region->ID][$resort->ID] = $resort->MenuTitle;
}
}
return json_encode($regionsArray);
}
The regions and resorts are essentially just page types. All good so far.
Now, I need to actually perform the search and display the results based on the regions (if any has been selected. If not show all) and resorts (again, if one has been selected, if not, show all in the region) but am at a complete loss where to even start with this.
I'm very new to silverstripe and OOP, having only done procedural programming previous to this so please treat me like an idiot in any responses to make things as clear as possible including which files to add various snippets of code to.
Many thanks.