Grokbase Groups PHP cake-php May 2012
FAQ
Hello all ,

I need some help on autocomplete,
I want to fetch merchant names from database.
Here is my code.

controller

<?php
class MerchantsController extends AppController {

var $name = 'Merchants';
var $uses =
array('Customer','Parameter','Merchant','Merchantcard','Merchantcustomfield');

var $helpers = array('Html','Form','Ajax','Javascript');
var $components = array('Session','Auth','RequestHandler');

function index() {
$this->set('title_for_layout', 'Select Merchant: Loyalty card');

$this->set('merchant',
$this->Merchant->find('all'));
}

function autoComplete() {
$this->set('merchants', $this->Merchant->find('all',
array( 'conditions' => array(
'Merchant.name LIKE' => '%a%' )
)));

$this->layout = 'ajax';
}

function beforeFilter() {
$this->Auth->allow('*'); } }

model


class Merchant extends AppModel {

var $name = 'Merchant';

}


views
index.ctp

<?php echo $form->create('Merchant', array('url' =>
'/merchants/index')); ?>
<?php echo $ajax->autoComplete('Merchant.name',
'/merchants/autoComplete')?>
<?php echo $form->end('find')?>

autocomplete.ctp
<ul> <?php foreach($merchants as $merchant): ?>
<li><?php echo $merchant['Merchant']['name']; ?></li>
<?php endforeach; ?> </ul>


Is there anything wrong in this code , following all steps from cake
documentation , i am using cakephp version 1.3

Thanks in advance,
Mangesh Sathe


--
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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcake-php @
categoriesphp
postedMay 15, '12 at 5:29a
activeMay 15, '12 at 5:29a
posts1
users1
websitecakephp.org
irc#cakephp

1 user in discussion

Mangesh Sathe: 1 post

People

Translate

site design / logo © 2022 Grokbase