Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/05/2014, 12:59
echo_
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Pasar variable de un metodo a otro

Buenos dias, intento tomar una variable de un metodo para mostrarlo en otro pero no puedo, este es mi ejemplo y la variable es $foo, en que estoy mal? ya que ocupo mandarla a una vista en ZEND

Código PHP:
     class ArtistaController extends Zend_Controller_Action{

          public 
$foo;

             public function 
init(){
                     
$this->initView();
                     
$this->view->baseUrl $this->_request->getBaseUrl();
             }

             

              public function 
addAction(){

                  
                     
$this->view->title "Agregar artista";
                     
$this->view->headTitle($this->view->title);
                     
$form = new Application_Form_Artista ();
                     
$form->submit->setLabel('Add');
                     
$this->view->form $form;

                     if (
$this->getRequest()->isPost()){
                         
$formData $this->getRequest()->getPost();

                             if (
$form->isValid($formData)){
                                 
// $artista_id = $form->getValue('artista_id');
                                 
$nombre $form->getValue('nombre');
                                 
$fecha_ingreso $form->getValue('fecha');
                                 
$descripcion $form->getValue('descripcion');
                                 
$email $form->getValue('email');

                                 
//cambio formato de fecha para mysql
                                 
$fecha $this->fechaMysql($fecha);
                                 
$artista = new Application_Model_DbTable_Artista ();
                                 
$artista->agregar($nombre$descripcion$email$fecha_ingreso);

                                 
$this->_helper->redirector('index');
                             }
                             else{
                                 
$form->populate($formData);
                             }
                     }
                     
$this->foo 'sd';
             }


             public function 
indexAction(){
                 
                     
$table = new Application_Model_DbTable_Artista();
                     
$this->view->datos $table->listar();
                                          
$this->view->name $this->foo;

             }