Ver Mensaje Individual
  #14 (permalink)  
Antiguo 07/10/2009, 07:43
tucuguara
 
Fecha de Ingreso: septiembre-2009
Mensajes: 27
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: problema validar con zend form

Hola que tal!! Te muestro como es que estoy tomando los valores:

EjemploController.php (ESTE ES EL CONTROLADOR DE LA VISTA DONDE TIPEO LOS CAMPOS)
public function enviarAction()
{

$request = $this->getRequest();
$form = new Default_Form_Ejemplo();
if ($this->getRequest()->isPost()) {
if ($form->isValid($request->getPost())) {
$variables = $form->getParems();
}
}
$form = new Default_Form_Ejemplo2($variables);
$this->view->form = $form;
}

Ejemplo2Controller.php (ESTE ES EL CONTROLADOR DE LA SEGUNDA PANTALLA QUE TIENEN LAS MISMAS CAJAS DE TEXTO, CHECKBOX, ETC, SOLO QUE NO TIENE BOTONES)
<?php
// application/controllers/Ejemplo2Controller.php

class Ejemplo2Controller extends Zend_Controller_Action
{
public function init()
{
$this->view->title = "Ejemplo Número II";
}

public function indexAction()
{
$form = new Default_Form_Ejemplo2();
$this->view->title = "Ejemplo Número II";
$this->view->form = $form;
}

public function salirAction()
{
$this->view->form = $form;
}
}


El Form_Ejemplo es:
<?php

class Default_Form_Ejemplo extends Zend_Form
{
public function init()
{
// Set the method for the display form to POST
$this->setMethod('post');

$this->addElement('text', 'correo', array(
'label' => 'Correo Electrónico',
'value' => '[email protected]',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array('EmailAddress',)
));

$this->addElement('textarea','direccion', array(
'label' => 'Dirección',
'value' => 'Tucupita',
'required' => true,
'rows' => '5',
'stringLength' => array(0, 250)
));

$this->addElement('checkbox', 'cheejemplo', array(
'label' => 'Usuario Nuevo',
'required' => true,
'checked' => true,
'checkboxvalue' => array('Natural','Jurídico'),
));

$this->addElement('radio','radejemplo',array(
'label' => 'Tipo Usuario',
'required' => true,
'multiOptions' => array(
'natural' => 'Natural',
'juridico' => 'Jurídico',),
));

$this->addElement('select','selejemplo',array(
'label' => 'Estado',
'value' => '',
'required' => true,
'autocomplete' => false,
'multiOptions' => array(
'seleccione' => 'Seleccione',
'carabobo' => 'Carabobo',
'capital' => 'Disttrito Capital',
'amacuro' => 'Delta Amacuro',
'lara' => 'Lara',
'zulia' => 'Zulia',),
));

$this->addElement('image', 'imaejemplo', array(
'label' => 'Foto',
));

$this->addElement('button', 'enviar', array(
'ignore' => true,
'label' => 'Enviar',
'onclick' => 'javascript:location.href= "./ejemplo/enviar"',
));

$this->addElement('reset', 'cancelar', array(
'ignore' => true,
'label' => 'Cancelar',
));

}
}
No entra por if ($this->getRequest()->isPost())... seguro me falta algo...

Gracias! espero que sirva de guia y puedas ayudarme!!!