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.

Data Model Questions /

ModelAdmin + searchable_fields + dropdown

Go to End

10 Posts   3425 Views


Community Member, 175 Posts

1 June 2011 at 9:37pm


the dropdown with the has_one relations now works ... but why I had no titles in my dropdown?
because the related DO had no "Title" field in database. I added this field to the "Account" DO and now this works.

for the many_many I'm still searching a solution.


where should I put this function or edit it?


Forum Moderator, 1805 Posts

1 June 2011 at 10:05pm

Edited: 01/06/2011 10:07pm

getSearchQuery($searchCriteria) in my ModelAdmin_CollectionController

class MyAdmin extends ModelAdmin {
   static $collection_controller_class = "MyAdmin_CollectionController";

class MyAdmin_CollectionController extends ModelAdmin_CollectionController {
   function getSearchQuery($searchCriteria) {
    $query = parent::getSearchQuery($searchCriteria);
    if ($this->modelClass == 'MyDataObject'){
    $query->where[] = 'EXISTS (SELECT 1 FROM SomeTable st'
    .' WHERE MyDataObject.ID = st.MyDataObjectID'
    .' AND st.Field='.$searchCriteria['MyFieldFromSearchFormFields'].')';
    return $query;

and I do you this to provide searching for complex relations where is has_one that has_one that has a man_many with 'xyz'...

Go to Top