17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1186 Views |
-
ComplexTableField and Search

11 September 2008 at 9:57pm
Anyone have experience of adding a search box on top of a complexTableField, so you can search within the table?
I have tried using the code for MemberTableField to do it, but keep running into issues.
Any help would be gratefully received,
This is what I have so far:
/**
* Extends a ComplexTableField by adding a search box to search within the table
*
*/class SearchComplexTableField extends ComplexTableField {
/**
* Template for main rendering
*
* @var string
*/
protected $template = "SearchComplexTableField";function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {
parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
// search
$SQL_search = isset($_REQUEST['TableSearch']) ? Convert::raw2sql($_REQUEST['TableSearch']) : null;
if(!empty($_REQUEST['TableSearch'])) {
$searchFilters = array();
foreach($fieldList as $fieldName => $fieldSpec) {
$searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'";
}
$this->sourceFilter[] = '(' . implode(' OR ', $searchFilters) . ')';
}
}
function SearchForm() {
$searchFields = new FieldGroup(
new TextField('TableSearch', _t('TableField.SEARCH', 'Search'))
);$actionFields = new LiteralField('ComplexTableFilterButton','<input type="submit" class="action" name="ComplexTableFilterButton" value="'._t('SearchComplexTableField.FILTER', 'Filter').'" id="ComplexTableFilterButton"/>');
$fieldContainer = new FieldGroup(
$searchFields,
$actionFields
);return $fieldContainer->FieldHolder();
}}
I get an error about missing Action.
Can someone point me in the right direction,
Thanks,
Adrian
-
Re: ComplexTableField and Search

12 September 2008 at 9:26pm
I have since managed to get this working. If anyone needs the solution, let me know.
Adrian
-
Re: ComplexTableField and Search

12 September 2008 at 9:53pm
Hi Adrian,
Would you mind posting the solution ?
| 1186 Views | ||
|
Page:
1
|
Go to Top |


