Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

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.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to add search filter in ComplexTableFields in the cms


Go to End


2 Posts   1600 Views

Avatar
ss_freebie

Community Member, 6 Posts

5 March 2010 at 12:12pm

Edited: 05/03/2010 12:20pm

Hi there,
I have added a dataobject in complextablefields to the cms but there are 300 rows in data. So I would like to add a simple search filter like in the image upload section to filter the results by names or something else.
I have read the doc in
http://doc.silverstripe.org/doku.php?id=dataobject
about this issue where mentions the followings:

$fields = singleton('MyDataObject')->searchableFields();
class MyDataObject extends DataObject {
static $searchable_fields = array(
'Name',
'ProductCode'
);
}

Here is my getCMSFields() function {

$fields = parent::getCMSFields();

$tablefield = new ComplexTableField(
$this,
'MyAdviser',
'Adviser',
array(
'Name' => "Name",
"Office"=>"Office",
'PostCode' => 'PostCode',
'Email' => "Email"
),
'getCMSFields_forPopup'
);

$tablefield->setParentClass('FindAdviser');
$tablefield->setAddTitle('an Adviser');

$fields->addFieldToTab( 'Root.Content.Adviser', $tablefield );
return $fields;

}

But I am not sure how I should put those lines into my page and dataobject to make it work, I did give it a go but no luck so far. Can any one here point me the direction ? Many thanks in advance.

Avatar
baba-papa

Community Member, 279 Posts

7 March 2010 at 5:03am

Use the DataObjectManager module to search your DataObjects in the Backend.

Are you a woman or a man? This is vital information for my communication behaviour.