06.01 php saved
dardosordi
Tags add more
 
Note
controller example for using with upload behaviour

model: http://bin.cakephp.org/view/1138231030

  1. <?php
  2. class FotosController extends AppController {
  3.  
  4.     var $name = 'Fotos';
  5.     var $helpers = array('Html', 'Form' , 'Image');
  6.  
  7.         function admin_add($id = null) {
  8.                 $this->layout = 'admin';
  9.         if(!empty($this->data)) {
  10.             $this->cleanUpFields();
  11.             $this->Foto->create();
  12.             if($this->Foto->save($this->data)) {
  13.                 $this->Session->setFlash('The Foto has been saved');
  14.                                 $this->redirect(array('controller' => 'galerias','action'=>'view', $this->data['Foto']['galeria_id']), null, true);
  15.             } else {
  16.                 $this->Session->setFlash('The Foto could not be saved. Please, try again.');
  17.             }
  18.         }
  19.                 $galerias = $this->Foto->Galeria->generateList(null, null, null, '{n}.Galeria.id', '{n}.Galeria.nombre');
  20.         $this->set(compact('galerias'));
  21.                 $this->set('galeria', $id);
  22.         }
  23.  
  24. }
  25. ?>
Parsed in 0.054 seconds, using GeSHi 1.0.7.14

Modify this Paste