3069 Posts in 868 Topics by 650 members
| Go to End | ||
| Author | Topic: | 2203 Views |
-
Re: ModelAdmin + searchable_fields + dropdown

1 June 2011 at 9:37pm
hi
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.
@swaiba:
where should I put this function or edit it?
-
Re: ModelAdmin + searchable_fields + dropdown

1 June 2011 at 10:05pm Last edited: 1 June 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'...
| 2203 Views | ||
| Go to Top |


