21279 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 970 Views |
-
Member based $searchable_fields

24 June 2009 at 7:26am
I have been told that to make $searchable_fields based on members group or permissions I have to use a public function searchableFields() instead of a static $searchable_fields. However I cannot figure out the syntax.
I need one set of searchable fields for one user group and another set for another user group for the same DataObject.
I figured it would be:
public function searchableFields() {
$member = Member::currentUser();
$searchable_fields = array(
'BestNotesID',
'FirstName',
'Surname',
'Therapist.FirstName',
'StudentGroup.Name'
);if ($member && $member->inGroups(array('office-staff', 'office-managers'))) {
$searchable_fields[] = 'OfficeLocation';
{return $searchable_fields;
}This code throws the error: Fatal error: Class 'B' not found in ....... sapphire/core/model/DataObject.php on line 1632
-
Re: Member based $searchable_fields

24 June 2009 at 1:13pm
If you define a searchableFields() method you need to to a bit of pre-processing yourself. Try returning this instead, as an example.
$searchable_fields = array(
'BestNotesID' => array(),
'FirstName' => array('title' => 'First name'),
'Surname' => array(),
'Therapist.FirstName' => array(),
'StudentGroup.Name => array()'
); -
Re: Member based $searchable_fields

25 June 2009 at 4:53am
Thanks for the help, I got it working. Now I need to make one of the search fields a dropdown instead of a text field. Is there a way to do this? The dropdown would be populated with the names of DataObjects of a particular class.
| 970 Views | ||
|
Page:
1
|
Go to Top |


