What does the resulting query look like? Does it include the condition with the submitted name?
On Mon, Apr 15, 2013 at 1:44 AM, Muhammad Asyraf <asyraf1...@gmail.com>wrote: > Actually i already Google several search plugin for CakePHP but most of > CakePHP user recommended search plugin from CakeDC. So, i download the > plugin from https://github.com/dereuromark/search and load the plugin > with code: CakePlugin::load('Search'); in bootstrap.php > > Then i implement the code for my file controller: > > public $components = array('Search.Prg'); > public $presetVars = true; // using the model configuration > public function find() { > $this->Prg->commonProcess(); > $this->paginate['conditions'] = > $this->Patient->parseCriteria($this->passedArgs); > $this->set('patients', $this->paginate()); > } > * > * > * > * > For the model, i put this code: > > public $actsAs = array('Search.Searchable'); > public $filterArgs = array( > array('name' => 'name', 'type' => 'query', 'method' => > 'filterName'), > ); > > public function filterName($data, $field = null) { > if (empty($data['name'])) { > return array(); > } > $nameField = '%' . $data['name'] . '%'; > return array( > 'OR' => array( > $this->alias . '.name LIKE' => $nameField, > )); > } > > For the view (find.ctp), i put this code for the form: (others code are > exactly same as view/index.ctp) > > <div><?php > echo $this->Form->create('Patient', array( > 'url' => array_merge(array('action' => 'find'), $this->params['pass']) > )); > echo $this->Form->input('name', array('div' => false)); > echo $this->Form->submit(__('Search'), array('div' => false)); > echo $this->Form->end(); > ?></div> > > > What i try to achieve is the search plugin will do searching for "name" > from table patients. However, this code seems not working but in the URL, > once i do searching for example i "John" as the search term, the URL bar > show as patients/find/name:john but the list of record are not showing john > record only but still show all records instead of john only. > > As for the information i use CakePHP ver: 2.3.1. Is it any problem with > the codes or any depreciate attributes in the coding? Sorry if this > question repeated in this group but i still unable to find any solution. > Most of the user claimed that it is easy to use this plugin but i'm still > new in CakePHP. Hope someone can help me. > > Thanks :) > > -- > 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 cake-php+unsubscr...@googlegroups.com. > To post to this group, send email to cake-php@googlegroups.com. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.