0

I have search working fine for the parent model, but I have no idea how to get child models/tables included in the Select portion of the query.

Using Cake 2.3.8

This article (how to use cakedc/search plugin for searching across 3 different tables with 1 search bar?) seems like the closest answer, but I'm new to cake and don't quite understand @mark's concise answer.

Any help would be much appreciated, Thanks!

Community
  • 1
  • 1
jnm
  • 1
  • 1
  • what is exactly the relationship between your Models? Can you make an example? – arilia Sep 27 '13 at 18:45
  • Thanks @arilia, I have a Books Model that has many Authors and many Awards. In my search, I would like to use one search bar. If a visitor searches using the title as the search term, it is fine since that data is in the Books table. However, I would also like to be able to search by the Author's name, and return all books by that author, but it is not working since I can't get cakeDC search to search the child models (authors and awards). – jnm Sep 27 '13 at 18:59

1 Answers1

0

Let me shorten the example from the readme.md for you, it should become obvious:

class Article extends AppModel {
    public $actsAs = array('Search.Searchable');
    public $belongsTo = array('User');
    public $filterArgs = array(
        'title' => array('type' => 'like'),
        'username' => array('type' => 'like', 'field' => array(
            'User.username', 'UserInfo.first_name')),
    );

Notice the Model.field notation for the username filter.

floriank
  • 25,546
  • 9
  • 42
  • 66