Thursday, June 28, 2012

Re: CakeDC Search plugin for CakePhp 2.0, multiple models

Hi all,

Plz excuse me for if i it is some thing stupid , but i tried using the search plugin, and have got stuck , at something , and had almost no clue to handle that.

in my find function in my controller, creates error at the line : $this->paginate['conditions'] = $this->Search->parseCriteria($this->passedArgs());

saying :  Call to a member function parseCriteria() on a non-object in C:\Projects\crush\Controller\SearchesController.php .

i tried using debug($this->passedArgs());  and it shows an empty array.

Have some1 else encountered this problem, bcoz i goolged , and could not get much. I think the problem is in declaraing passed args. But i have done as per instructed, and can't see any error in that. 



On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

On Thursday, June 21, 2012 11:36:39 AM UTC+5:30, DiabloGeto wrote:
Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There are lot of search options, that means a user can be searched from any of his attributes or combination of all.   Further i have a search table  which is to save all the searches done by users. My user table has basic user info like first name , last name , email, and log in info.  Rest is in profile. i have but all the associations requited in the models.  I am not sure weather to implement search plugin on user model or search model.

On Sunday, June 17, 2012 4:43:03 AM UTC+5:30, Bob Bowen wrote:
Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' => array('Article.name', 'OtherModel.name'))
  }
}

But what is not explained is, how do I get the plugin to actually search within the 'OtherModel' Model? I ask because later in the Controller you have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Article->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }
}

And in the .ctp you have:

echo $this->Form->create('Article', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to search for a field from another model, like the 'OtherModel.name' example above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE '%foo%') OR (`OtherModel`.`name` LIKE '%foo%')) 

Obviously OtherModel.name is not going to be found in Article. 

What I need to do is have a general Search box that searches in 4-5 different Models. There is no relation between those Models. So I am not sure which Model to put the filterArgs array, which Controller to put the presetVars array and find() function, and how to call it all in my .ctp so that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!

On Friday, June 15, 2012 10:08:11 AM UTC+2, euromark wrote:
try this one:

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')


Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:
Is there any way to make this work? As I understand it you have to enable Search.Searchable in the $actsAs, and define $filterArgs for each Model, then add Search.Prg to $components and define $presetVars in the Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to define a search form with one search field and have it look in various fields within various Models?

Thanks
Bob

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: