'subject' => 'subject'
where did you get that from? sure not the documentation :)
it should read:
public $filterArgs = array(
'subject' => array('type' => 'query', 'method' => 'filterSubject'),
);
Am Montag, 22. Juli 2013 06:38:53 UTC+2 schrieb Asyraf Wahi Anuar:
>
> Hi,
>
> CakePHP version: 2.3.6
>
> i try to implement the CakeDC search function by add this code to my
> controller:
>
> class QuestionsController extends AppController {
> public $paginate = array(); //create array for record page
> public $components = array('Search.Prg');
> public $presetVars = true; // using the model configuration
> public function find() {
> $this->Prg->commonProcess();
> $this->paginate['conditions'] =
> $this->Question->parseCriteria($this->passedArgs);
> $this->set('questions', $this->paginate());
> }
>
> then i add this code to model:
>
> public $actsAs = array('Search.Searchable');
> public $filterArgs = array(
> array('subject' => 'subject', 'type' => 'query', 'method' =>
> 'filterSubject'),
> );
> public function filterSubject($data, $field = null) {
> if (empty($data['subject'])) {
> return array();
> }
> $subjectField = '%' . $data['subject'] . '%';
> return array(
> 'OR' => array(
> $this->alias . '.subject LIKE' => $subjectField,
> ));
> }
>
> and the last part is to add the form:
>
> <div><?php
> echo $this->Form->create('Question');
> echo $this->Form->input('subject', array('div' => false));
> echo $this->Form->submit(__('Search'), array('div' => false));
> echo $this->Form->end();
> ?></div>
>
> But this scrip does not work. Is it any problem with the code? FYI, i have
> table name "questions" and inside the table, i have several field such as
> id, subject, code, etc... so what i try to do is to do searching based on
> the subject. Anybody can assist me?
>
> Thank you :)
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.