Hi, I'm trying to implement the custom search context code from the wiki here. I'm using the following:
The dataobject is 'Product' and has
static $searchable_fields = array(
'Description',
'ProductCode'
);
The form/ search function is:
public function SearchForm() {
$context = singleton('Product')->getDefaultSearchContext();
$fields = $context->getSearchFields();
$form = new Form($this, "SearchForm",
$fields,
new FieldSet(
new FormAction('doSearch')
)
);
return $form;
}
public function doSearch($data, $form) {
$context = singleton('Product')->getDefaultSearchContext();
$results = $context->getResults($data);
return $this->customise(array(
'Results' => $results
))->renderWith('Page_results');
}
...but, this gives me 2 fields on the form (Description & Product Code). I really only want one form field on the front-end of the site (ie keywords) but want it to search both Description and product code.
Any ideas on this?