Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/02/2013, 13:25
wilmer30
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
formas de usar decordador ViewScript

Hola, Me estoy rompiendo la cabeza por querer armar esto con decorator viewScript, esto es lo que deseo hacer:
Código HTML:
Ver original
  1. <form id="login">
  2.     <h1>Restrici&oacute;n</h1>
  3.     <fieldset id="inputs">
  4.         <input id="username" placeholder="Username" autofocus required type="text">  
  5.         <input id="password" placeholder="Password" required type="password">
  6.     </fieldset>
  7.     <fieldset id="actions">
  8.         <input id="submit" value="Aceptar" type="submit">
  9.         <a href="">Reg&iacute;strate</a>
  10.     </fieldset>
  11. </form>

y este es mi form:
Código PHP:
Ver original
  1. class Application_Form_LoginForm extends Zend_Form {
  2.    
  3.     public function init() {
  4.        
  5.         $this->setDisableLoadDefaultDecorators(true);
  6.        
  7.         $this->setDecorators(array(
  8.                 array ('ViewScript',    array('viewScript'  => 'login/_login.phtml' )),
  9.                 array ('HtmlTag',       array ('tag' => 'dl','id' => 'login' ) ),
  10.                 array ('Description',   array ('placement' => 'prepend') ),
  11.                 'Form'
  12.         ));
  13.        
  14.        
  15.         $this->setMethod('post');
  16.         $this->setAction('');
  17.        
  18.        
  19.         $username = $this->addElement ( 'text', 'username', array (
  20.                 'filters' => array ( 'StringTrim',  'StringToLower' ),
  21.                 'validators' => array ( 'Alpha', array ( 'StringLength',false, array (  3,20 ) ) ),
  22.                 'required' => true,
  23.                 'label' => 'Usuario:'
  24.         ) );
  25.        
  26.         $password = $this->addElement ( 'password', 'password', array (
  27.                 'filters' => array ('StringTrim'),
  28.                 'validators' => array ('Alnum', array ( 'StringLength', false,  array ( 6,  20 ) ) ),
  29.                 'required' => true,
  30.                 'label' => 'Contraseña:'
  31.         ) );
  32.        
  33.        
  34.         $login = $this->addElement ( 'submit', 'login', array (
  35.                 'required' => false,
  36.                 'ignore' => true,
  37.                 'label' => 'Ingresar'              
  38.         ) );
  39. //      'decorators' => array(
  40. //              'ViewHelper',
  41. //              array ('HtmlTag',   array ('tag' => 'dl','id' => 'login' ) ) )
  42.         // We want to display a 'failed authentication' message if necessary;
  43.         // we'll do that with the form 'description', so we need to add that
  44.         // decorator.
  45. //      $this->addDecorators (
  46. //              array ('FormElements',
  47. //              array ('HtmlTag',       array ('tag' => 'dl','id' => 'login' ) ),
  48. //              array ('Description',   array ('placement' => 'prepend') ),
  49. //              'Form'
  50. //      ) );
  51.     }
  52.    
  53. }
este mi _login.phtml
Código HTML:
Ver original
  1. <h1>Restrici&oacute;n</h1>
  2. <fieldset id="inputs">
  3.  
  4. <?php echo $this->element->getElement('username'); ?>
  5. <?php echo $this->element->password; ?>
  6.  
  7. <fieldset id="actions">
  8. <?php echo $this->element->getElement('login'); ?>
  9. <a href="">Reg&iacute;strate</a>
y mi salida es este, que es totalmente diferente:
Código HTML:
Ver original
  1. <form enctype="application/x-www-form-urlencoded" action="" method="post"><dl id="login">
  2.  
  3. <h1>Restrici&oacute;n</h1>
  4. <fieldset id="inputs">
  5.  
  6. <dt id="username-label"><label for="username" class="required">Usuario:</label></dt>
  7. <dd id="username-element">
  8. <input type="text" name="username" id="username" value="" /></dd><dt id="password-label"><label for="password" class="required">Contraseña:</label></dt>
  9. <dd id="password-element">
  10. <input type="password" name="password" id="password" value="" /></dd>
  11. <fieldset id="actions">
  12. <dt id="login-label">*</dt><dd id="login-element">
  13. <input type="submit" name="login" id="login" value="Ingresar" /></dd><a href="">Reg&iacute;strate</a>
  14.  
  15. </dl></form>

gracias de antemano