Thursday, May 16, 2013

search by field

I have 

show.ctp
--------------
<?php 
foreach ($prod as $p):
    echo $p['Producto']['id'];
    echo $p['Producto']['descripcion'];
endforeach;
?>


Producto.php (model)
-------------------------------
    public function getProducto($descripcion = null) {
        $this->find('all', array('conditions' => array('descripcion' => $descripcion)));
}


and controller ProductosController.php
--------------------------------------------------------
    public function show() {
        $descripcion = $this->request->data['Producto']['search'];
        $prod = $this->Producto->getProducto($descripcion);
        $this->set(compact('prod'));
}


but not work :(

Warning (2): Invalid argument supplied for foreach() [APP\View\Productos\show.ctp, line 2]

--
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+unsubscribe@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.
 
 

No comments: