Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/04/2011, 20:33
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Zend_Validate_Callback

Oh y se me olvidaba, el formulario
Código PHP:
Ver original
  1. <?php
  2. class Reports_Form_Foo extends Zend_Form
  3. {
  4.     public function init()
  5.     {
  6.         $n=1;
  7.         // initialize form
  8.         $this->setMethod('post')
  9.             ->setAttrib('accept-charset', 'utf-8')
  10.             ->setDecorators(
  11.                 array(
  12.                     'FormElements',
  13.                     'Form',
  14.                 )
  15.             );
  16.  
  17.         // create select input for foo
  18.         $foo = new Zend_Form_Element_Select('foo');
  19.         $foo->setLabel('Foo:')
  20.             ->setDecorators(
  21.                 array(
  22.                     'Description',
  23.                     'Errors',
  24.                     'ViewHelper',
  25.                     array('HtmlTag', array('tag'=>'div')),
  26.                     array('Label', array('tag'=>'div')),
  27.                 )
  28.             )
  29.             ->setOptions(array('tabindex'=>$n++));
  30.         $fooArray = array(
  31.             ''=>'[Selecciona uno]',
  32.             'Foo' => array(
  33.                 1=>'Foo',
  34.                 2=>'Bar'
  35.             ),
  36.             'Baz' => array(
  37.                 3=>'Baz',
  38.                 4=>'Candy',
  39.                 5=>'Fruits'
  40.             ),
  41.         );
  42.         $foo->addMultiOptions($fooArray);
  43.  
  44.         // create submit button
  45.         $submit = new Zend_Form_Element_Submit('submit');
  46.         $submit->setLabel('Submit')
  47.             ->setOptions(array('class' => 'submit', 'tabindex'=>$n++))
  48.             ->setDecorators(
  49.                 array(
  50.                     'ViewHelper',
  51.                     array('HtmlTag', array('tag'=>'div')),
  52.                 )
  53.             );
  54.  
  55.  
  56.         $this->addElements(
  57.             array(
  58.                 $foo,
  59.                 $submit
  60.             )
  61.         );
  62.     }
  63. }
Logicamente aquí no coloqué que está disable, en mi formulario si lo está, pero para que funcione lo coloqué aquí así.
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos

Última edición por abimaelrc; 22/04/2011 a las 21:48