Hola, Me estoy rompiendo la cabeza por querer armar esto con decorator viewScript, esto es lo que deseo hacer:
Código HTML:
Ver original <h1>Restrici
ón
</h1> <input id="username" placeholder="Username" autofocus required type="text"> <input id="password" placeholder="Password" required type="password"> <input id="submit" value="Aceptar" type="submit"> <a href="">Reg
ístrate
</a>
y este es mi form:
Código PHP:
Ver originalclass Application_Form_LoginForm extends Zend_Form {
public function init() {
$this->setDisableLoadDefaultDecorators(true);
$this->setDecorators(array( array ('ViewScript', array('viewScript' => 'login/_login.phtml' )), array ('HtmlTag', array ('tag' => 'dl','id' => 'login' ) ), array ('Description', array ('placement' => 'prepend') ), 'Form'
));
$this->setMethod('post');
$this->setAction('');
$username = $this->addElement ( 'text', 'username', array ( 'filters' => array ( 'StringTrim', 'StringToLower' ), 'validators' => array ( 'Alpha', array ( 'StringLength',false, array ( 3,20 ) ) ), 'required' => true,
'label' => 'Usuario:'
) );
$password = $this->addElement ( 'password', 'password', array ( 'filters' => array ('StringTrim'), 'validators' => array ('Alnum', array ( 'StringLength', false, array ( 6, 20 ) ) ), 'required' => true,
'label' => 'Contraseña:'
) );
$login = $this->addElement ( 'submit', 'login', array ( 'required' => false,
'ignore' => true,
'label' => 'Ingresar'
) );
// 'decorators' => array(
// 'ViewHelper',
// array ('HtmlTag', array ('tag' => 'dl','id' => 'login' ) ) )
// We want to display a 'failed authentication' message if necessary;
// we'll do that with the form 'description', so we need to add that
// decorator.
// $this->addDecorators (
// array ('FormElements',
// array ('HtmlTag', array ('tag' => 'dl','id' => 'login' ) ),
// array ('Description', array ('placement' => 'prepend') ),
// 'Form'
// ) );
}
}
este mi _login.phtml
Código HTML:
Ver original<h1>Restrici
ón
</h1>
<?php echo $this->element->getElement('username'); ?>
<?php echo $this->element->password; ?>
<?php echo $this->element->getElement('login'); ?>
<a href="">Reg
ístrate
</a>
y mi salida es este, que es totalmente diferente:
Código HTML:
Ver original<form enctype="application/x-www-form-urlencoded" action="" method="post"><dl id="login">
<h1>Restrici
ón
</h1>
<dt id="username-label"><label for="username" class="required">Usuario:
</label></dt> <dd id="username-element"> <input type="text" name="username" id="username" value="" /></dd><dt id="password-label"><label for="password" class="required">Contraseña:
</label></dt> <dd id="password-element"> <input type="password" name="password" id="password" value="" /></dd> <dt id="login-label">*
</dt><dd id="login-element"> <input type="submit" name="login" id="login" value="Ingresar" /></dd><a href="">Reg
ístrate
</a>
gracias de antemano