Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Pages: 1
Bonjour,
C'est encore moi
Désolé de vous ennuyez mais décidément je ne comprends pas.
J'ai transformé mes display group en subform hier et avec un code similaire je me retrouve avec des balise <dd></dd> non désirée ...
Pourriez-vous y jeter un oeil svp ?
Voilà mon formulaire :
<?php class Default_Form_LoginGuest extends Zend_Form { public function init() { // Set the method for the form to POST $this->setMethod('post') ->setAction('index') ->setDescription('formulaire de login') ->setEnctype(Zend_Form::ENCTYPE_URLENCODED) ->setLegend('login') ->setName("login_guest_form"); // Create Subforms $login_with_password = new Zend_Form_SubForm(); $login_with_captcha = new Zend_Form_SubForm(); // Add a login element $login_with_password->addElement('text', 'login', array( 'label' => 'Login name :', 'required' => false, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(6, 20))), //'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your login name', 'id' => 'login', 'class' => 'fixed', ) ); // Add a password element $login_with_password->addElement('password', 'password', array( 'label' => 'Secret password :', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), // 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your secret password', 'id' => 'password', 'class' => 'fixed', ) ); $login_with_password->addElement('checkbox', 'remember_me', array( 'label' => 'Remember me :', 'required' => false, //'description' => 'Remeber your login and password ?', 'id' => 'remember_me', 'class' => 'fixed', ) ); // Add a captcha $login_with_captcha->addElement('captcha', 'captcha', array( 'label' => '5 letters displayed :', //'description' => 'Enter the captcha below for anonymous surfing', 'class' => 'fixed', 'required' => false, 'validators' => array(array('StringLength', false, array(5, 5))), // 'ErrorMessages' => array('required'=>'Element requis'), 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 5, 'timeout' => 300, 'width' => 106, 'height' => 35, 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 3, 'font' => APPLICATION_PATH . '/../public/fonts/arial.ttf', 'fontSize' => 25, 'imgDir' => APPLICATION_PATH . '/../public/img/captcha/', 'imgUrl' => '/img/captcha/', ) ) ); // Add the submit button $this->addElement('submit', 'submit_login_guest', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed', //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $this->addElement('hash', 'csrf_login_guest', array( 'ignore' => true, ) ); // Here comes the display group : // $this->addDisplayGroup( array('captcha'), // 'login_with_captcha', // array() // ); // // $this->addDisplayGroup( array('login','password','remember_me'), // 'login_with_password', // array() // ); // Here comes the subform : $this->addSubForm($login_with_captcha, 'login_with_captcha', array() ); $this->addSubform($login_with_password, 'login_with_password', array() ); /*#######################################*/ /*###### Here comes the decorators ######*/ /*#######################################*/ $this->clearDecorators(); /*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ), array( null ), array( null ) ); // /*Set Commons group Decorators*/ // $this->setDisplayGroupDecorators(array( // array('FormElements') ), // array( // null // ), // array( // null // ) // ); /*Set Commons group Decorators*/ $this->setSubFormDecorators(array( array('FormElements') ), array( null ), array( null ) ); // /*Add Specific group Decorators*/ // $this->getDisplayGroup('login_with_password')->addDecorators(array( // array('Fieldset', array('class' => 'fixed', // 'legend' => 'login with password') // ) // )); // // // $this->getDisplayGroup('login_with_captcha')->addDecorators(array( // array('Fieldset', array('class' => 'fixed', // 'legend' => 'login with captcha') // ) // )); /*Add Specific Subgroup Decorators*/ $this->getSubForm('login_with_password')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with password') ) )); $this->getSubForm('login_with_captcha')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with captcha') ) )); /*Set form specific elements Decorators*/ $this->getSubForm('login_with_captcha')->getElement('captcha')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('login')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('password')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('remember_me')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); /*Set form commons elements Decorators*/ $this->setElementDecorators(array( array('ViewHelper'), //array('Errors'), //array('Description', array('tag' => 'p', 'class' => 'description')), //array('HtmlTag', array('tag' => 'dd')), //array('Label', array('tag' => 'dt')), //array('Label', array('tag' => 'dl')), ) ); } }
et voilà le résultat en html des deux sous-formulaires :
<fieldset id="fieldset-login_with_password" class="fixed"><legend>login with password</legend> <label for="login" class="fixed optional">Login name :</label> <dd id="login-element"> <input type="text" name="login_with_password[login]" id="login" value="" class="fixed"></dd> <label for="password" class="fixed optional">Secret password :</label> <dd id="password-element"> <input type="password" name="login_with_password[password]" id="password" value="" class="fixed"></dd> <label for="remember_me" class="fixed optional">Remember me :</label> <dd id="remember_me-element"> <input type="hidden" name="login_with_password[remember_me]" value="0"><input type="checkbox" name="login_with_password[remember_me]" id="remember_me" value="1" class="fixed"></dd></fieldset><fieldset id="fieldset-login_with_captcha" class="fixed"><legend>login with captcha</legend> <label for="login_with_captcha[captcha]-input" class="fixed required">5 letters displayed :</label> <dd> <img width="106" height="35" alt="" src="/img/captcha/c1f0d07b3a57727413914a93c71923d9.png"/><br/> <input type="hidden" name="login_with_captcha[captcha][id]" value="c1f0d07b3a57727413914a93c71923d9" class="fixed" id="login_with_captcha-captcha-id"> <input type="text" name="login_with_captcha[captcha][input]" id="login_with_captcha-captcha-input" value="" class="fixed"></dd></fieldset>
merci d'avance à tous ceux qui se pencheront sur le problème
Dernière modification par daverck (18-09-2009 18:20:35)
Hors ligne
Rebonjour,
en fait j'ai un problème qui m'ennuie encore plus maintenant :-/
Je n'arrive pas à ajouter un bouton pour poster;
en fait le bouton est la mais il n'a pas d'attributs "method" ni "action"
pourtant à la ligne 16 de mon code je les ais précisés :
<?php class Default_Form_LoginGuest extends Zend_Form { public function init() { // Set the method for the form to POST $this->setDescription('formulaire de login') ->setEnctype(Zend_Form::ENCTYPE_URLENCODED) ->setLegend('login') ->setName("login_guest_form"); // Create Subforms and "init" subform $login_with_password = new Zend_Form_SubForm(); $login_with_password->setAction('index') ->setMethod('post'); $login_with_captcha = new Zend_Form_SubForm(); $login_with_captcha->setAction('index') ->setMethod('post'); // Association of subform with the form : $this->addSubForm($login_with_captcha, 'login_with_captcha', array() ); $this->addSubform($login_with_password, 'login_with_password', array() ); // Add a login element $login_with_password->addElement('text', 'login', array( 'label' => 'Login name :', 'required' => false, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(6, 20))), //'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your login name', 'id' => 'login', 'class' => 'fixed', ) ); // Add a password element $login_with_password->addElement('password', 'password', array( 'label' => 'Secret password :', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), // 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your secret password', 'id' => 'password', 'class' => 'fixed', ) ); $login_with_password->addElement('checkbox', 'remember_me', array( 'label' => 'Remember me :', 'required' => false, //'description' => 'Remeber your login and password ?', 'id' => 'remember_me', 'class' => 'fixed', ) ); // Add a submit button $login_with_password->addElement('submit', 'submit_login_with_password', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed', //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $login_with_password->addElement('hash', 'csrf_login_with_password', array( 'ignore' => true, ) ); // Add a captcha $login_with_captcha->addElement('captcha', 'captcha', array( 'label' => '5 letters displayed :', //'description' => 'Enter the captcha below for anonymous surfing', 'class' => 'fixed', 'required' => false, 'validators' => array(array('StringLength', false, array(5, 5))), // 'ErrorMessages' => array('required'=>'Element requis'), 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 5, 'timeout' => 300, 'width' => 106, 'height' => 35, 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 3, 'font' => APPLICATION_PATH . '/../public/fonts/arial.ttf', 'fontSize' => 25, 'imgDir' => APPLICATION_PATH . '/../public/img/captcha/', 'imgUrl' => '/img/captcha/', ) ) ); // Add a submit button $login_with_captcha->addElement('submit', 'submit_login_with_captcha', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed', //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $login_with_captcha->addElement('hash', 'csrf_login_with_captcha', array( 'ignore' => true, ) ); // //Here comes the display group : // $this->addDisplayGroup( array('captcha','login','password','remember_me','submit_login_guest','csrf_login_guest'), // 'login_guest_displaygroup', // array() // ); // // $this->addDisplayGroup( array('login','password','remember_me'), // 'login_with_password', // array() // ); /*#######################################*/ /*###### Here comes the decorators ######*/ /*#######################################*/ $this->clearDecorators(); /*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ), array( null ), array( null ) ); /*Set Commons group Decorators*/ $this->setDisplayGroupDecorators(array( array('FormElements') ), array( null ), array( null ) ); /*Set subform Decorators*/ $this->setSubFormDecorators(array( array('FormElements') ), array( null ), array( null ) ); // /*Add Specific group Decorators*/ // $this->getDisplayGroup('login_guest_displaygroup')->addDecorators(array( // array('Fieldset', array('class' => 'fixed') // ) // )); // // // $this->getDisplayGroup('login_with_captcha')->addDecorators(array( // array('Fieldset', array('class' => 'fixed', // 'legend' => 'login with captcha') // ) // )); /*Add Specific Subgroup Decorators*/ $this->getSubForm('login_with_password')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with password') ) )); $this->getSubForm('login_with_captcha')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with captcha') ) )); /*Set form specific elements Decorators*/ $this->getSubForm('login_with_captcha')->getElement('captcha')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('login')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('password')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('remember_me')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); /*Set form commons elements Decorators*/ $this->setElementDecorators(array( array('ViewHelper'), //array('Errors'), //array('Description', array('tag' => 'p', 'class' => 'description')), //array('HtmlTag', array('tag' => 'dd')), //array('Label', array('tag' => 'dt')), //array('Label', array('tag' => 'dl')), ) ); } }
l'adresse de l'action n'est pas le problème puisque l'attribut "action" n'apparais même pas :
authentication<fieldset id="fieldset-login_with_password" class="fixed"><legend>login with password</legend> <label for="login" class="fixed optional">Login name :</label> <dd id="login-element"> <input type="text" name="login_with_password[login]" id="login" value="" class="fixed"></dd> <label for="password" class="fixed optional">Secret password :</label> <dd id="password-element"> <input type="password" name="login_with_password[password]" id="password" value="" class="fixed"></dd> <label for="remember_me" class="fixed optional">Remember me :</label> <dd id="remember_me-element"> <input type="hidden" name="login_with_password[remember_me]" value="0"><input type="checkbox" name="login_with_password[remember_me]" id="remember_me" value="1" class="fixed"></dd> <dt id="submit_login_with_password-label"> </dt><dd id="submit_login_with_password-element"> <input type="submit" name="login_with_password[submit_login_with_password]" id="login_with_password-submit_login_with_password" value="OK" class="fixed"></dd> <dt id="csrf_login_with_password-label"> </dt> <dd id="csrf_login_with_password-element"> <input type="hidden" name="login_with_password[csrf_login_with_password]" value="d7afe98c3330929c2d419ddf7c11093e" id="login_with_password-csrf_login_with_password"></dd></fieldset><fieldset id="fieldset-login_with_captcha" class="fixed"><legend>login with captcha</legend> <label for="login_with_captcha[captcha]-input" class="fixed required">5 letters displayed :</label> <dd> <img width="106" height="35" alt="" src="/img/captcha/fc128efad3cc377065657c2d1443610d.png"/><br/> <input type="hidden" name="login_with_captcha[captcha][id]" value="fc128efad3cc377065657c2d1443610d" class="fixed" id="login_with_captcha-captcha-id"> <input type="text" name="login_with_captcha[captcha][input]" id="login_with_captcha-captcha-input" value="" class="fixed"></dd> <dt id="submit_login_with_captcha-label"> </dt><dd id="submit_login_with_captcha-element"> <input type="submit" name="login_with_captcha[submit_login_with_captcha]" id="login_with_captcha-submit_login_with_captcha" value="OK" class="fixed"></dd> <dt id="csrf_login_with_captcha-label"> </dt> <dd id="csrf_login_with_captcha-element"> <input type="hidden" name="login_with_captcha[csrf_login_with_captcha]" value="709c9561466d7e55eb97237b9c4820b3" id="login_with_captcha-csrf_login_with_captcha"></dd></fieldset>
Aussi si il y avait moyen de mettre un bouton de submit pour les deux subforms (pour le formulaire quoi) ça serait formidable.
Dites moi si je n'ai pas précisé assez de renseignement
merci d'avance
Hors ligne
daverck a écrit:
en fait le bouton est la mais il n'a pas d'attributs "method" ni "action"
Ca c'est normal ces attributs sont des attributs de la balise form
Hors ligne
merci ^^
du coup ça veux dire que les sous-formulaire doivent être entouré d'une balise form chacun et que que je ne peut pas mettre d'éléments commun !
Je crois que j'ai comprit ! ;-)
et il faudrait peut-être aussi que je vire les décorateurs pour les sous-formulaires spécifiquement au lieu du formulaire ! Ca expliquerait les <dd> et autres !
Hors ligne
mais non ! t'es pas obligé de mettre des <form> pour tes sous formulaires à moins de vouloir séparé les actions pour chaque formulaires, si tu mets juste le décorateur FormElements à tes sous formulaires, ca suffit. Le ZF, se charge de faire des tableaux dans le $_POST avec pour clé le nom de tes sous-formulaires.
Hors ligne
mais non ! t'es pas obligé de mettre des <form> pour tes sous formulaires à moins de vouloir séparé les actions pour chaque formulaire
Je préférerais n'avoir qu'une seule action et un seul bouton en fait.
si tu mets juste le décorateur FormElements à tes sous formulaires, ca suffit
Mais alors pourquoi je n'ai pas de balise form avec le code suivant ?
<?php class Default_Form_LoginGuest extends Zend_Form { public function init() { // Set the method for the form to POST $this->setDescription('formulaire de login') ->setEnctype(Zend_Form::ENCTYPE_URLENCODED) ->setLegend('login') ->setName("login_guest_form") ->setAction('index') ->setMethod('post'); // Create Subforms $login_with_password = new Zend_Form_SubForm(); $login_with_captcha = new Zend_Form_SubForm(); // Association of subform with the form : $this->addSubForm($login_with_captcha, 'login_with_captcha', array() ); $this->addSubform($login_with_password, 'login_with_password', array() ); // Add a login element $login_with_password->addElement('text', 'login', array( 'label' => 'Login name :', 'required' => false, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your login name', 'id' => 'login', 'class' => 'fixed', ) ); // Add a password element $login_with_password->addElement('password', 'password', array( 'label' => 'Secret password :', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your secret password', 'id' => 'password', 'class' => 'fixed', ) ); $login_with_password->addElement('checkbox', 'remember_me', array( 'label' => 'Remember me :', 'required' => false, //'description' => 'Remeber your login and password ?', 'id' => 'remember_me', 'class' => 'fixed', ) ); // Add a captcha $login_with_captcha->addElement('captcha', 'captcha', array( 'label' => '5 letters displayed :', //'description' => 'Enter the captcha below for anonymous surfing', 'class' => 'fixed', 'required' => false, 'validators' => array(array('StringLength', false, array(5, 5))), 'ErrorMessages' => array('required'=>'Element requis'), 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 5, 'timeout' => 300, 'width' => 106, 'height' => 35, 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 3, 'font' => APPLICATION_PATH . '/../public/fonts/arial.ttf', 'fontSize' => 25, 'imgDir' => APPLICATION_PATH . '/../public/img/captcha/', 'imgUrl' => '/img/captcha/', ) ) ); // Add a submit button $this->addElement('submit', 'submit_login_with_captcha', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed', //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $this->addElement('hash', 'csrf_login_guest', array( 'ignore' => true, ) ); /*#######################################*/ /*###### Here comes the decorators ######*/ /*#######################################*/ /*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ), array( null ), array( null ) ); /*Set subform Decorators*/ $this->setSubFormDecorators(array( array('FormElements') ), array( null ), array( null ) ); /*Add Specific Subgroup Decorators*/ $this->getSubForm('login_with_password')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with password') ) )); $this->getSubForm('login_with_captcha')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with captcha') ) )); /*Set form specific elements Decorators*/ $this->getSubForm('login_with_captcha')->getElement('captcha')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('login')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('password')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('remember_me')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); /*Set form commons elements Decorators*/ $this->setElementDecorators(array( array('ViewHelper'), //array('Errors'), //array('Description', array('tag' => 'p', 'class' => 'description')), //array('HtmlTag', array('tag' => 'dd')), //array('Label', array('tag' => 'dt')), //array('Label', array('tag' => 'dl')), ) ); } }
C'est comme si les lignes suivantes n'agissait pas en fait :
/*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ), array( null ), array( null ) );
Ou peut-être que je dois faire un display group pour mettre mes sous-formulaire dedans avec le bouton submit ...
Qu'est-ce que vous en dites ?
Voilà le rendu html pour ceux que ça intéresse : ;-)
<fieldset id="fieldset-login_with_password" class="fixed"><legend>login with password</legend> <label for="login" class="fixed optional">Login name :</label> <dd id="login-element"> <input type="text" name="login_with_password[login]" id="login" value="" class="fixed"></dd> <label for="password" class="fixed optional">Secret password :</label> <dd id="password-element"> <input type="password" name="login_with_password[password]" id="password" value="" class="fixed"></dd> <label for="remember_me" class="fixed optional">Remember me :</label> <dd id="remember_me-element"> <input type="hidden" name="login_with_password[remember_me]" value="0"><input type="checkbox" name="login_with_password[remember_me]" id="remember_me" value="1" class="fixed"></dd></fieldset><fieldset id="fieldset-login_with_captcha" class="fixed"><legend>login with captcha</legend> <label for="login_with_captcha[captcha]-input" class="fixed required">5 letters displayed :</label> <dd> <img width="106" height="35" alt="" src="/img/captcha/e73d15971aa2ad3ac5b14d4b7609e2ba.png"/><br/> <input type="hidden" name="login_with_captcha[captcha][id]" value="e73d15971aa2ad3ac5b14d4b7609e2ba" class="fixed" id="login_with_captcha-captcha-id"> <input type="text" name="login_with_captcha[captcha][input]" id="login_with_captcha-captcha-input" value="" class="fixed"></dd></fieldset>
Hors ligne
Sincèrement comment se fait-il que je n'ai pas de bouton submit ?!§
J'ai passé les options correctement :
<?php class Default_Form_LoginGuest extends Zend_Form { public function init() { // Set the method for the form to POST $this->setDescription('formulaire de login') ->setEnctype(Zend_Form::ENCTYPE_URLENCODED) ->setLegend('login') ->setName("login_guest_form") ->setAction('index') ->setMethod('post'); // Create Subforms $login_with_password = new Zend_Form_SubForm(); $login_with_captcha = new Zend_Form_SubForm(); // Association of subform with the form : $this->addSubForm($login_with_captcha, 'login_with_captcha', array() ); $this->addSubform($login_with_password, 'login_with_password', array() ); // Add a submit button $this->addElement('submit', 'submit_login_guest', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed', //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $this->addElement('hash', 'csrf_login_guest', array( 'ignore' => true, ) ); // Add a login element $login_with_password->addElement('text', 'login', array( 'label' => 'Login name :', 'required' => true, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your login name', 'id' => 'login', 'class' => 'fixed', ) ); // Add a password element $login_with_password->addElement('password', 'password', array( 'label' => 'Secret password :', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your secret password', 'id' => 'password', 'class' => 'fixed', ) ); $login_with_password->addElement('checkbox', 'remember_me', array( 'label' => 'Remember me :', 'required' => false, //'description' => 'Remeber your login and password ?', 'id' => 'remember_me', 'class' => 'fixed', ) ); // Add a captcha $login_with_captcha->addElement('captcha', 'captcha', array( 'label' => '5 letters displayed :', //'description' => 'Enter the captcha below for anonymous surfing', 'class' => 'fixed', 'required' => true, 'validators' => array(array('StringLength', false, array(5, 5))), 'ErrorMessages' => array('required'=>'Element requis'), 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 5, 'timeout' => 300, 'width' => 106, 'height' => 35, 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 3, 'font' => APPLICATION_PATH . '/../public/fonts/arial.ttf', 'fontSize' => 25, 'imgDir' => APPLICATION_PATH . '/../public/img/captcha/', 'imgUrl' => '/img/captcha/', ) ) ); /*#######################################*/ /*###### Here comes the decorators ######*/ /*#######################################*/ /*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ) ); /*Set subform Decorators*/ $this->setSubFormDecorators(array( array('FormElements') ) ); /*Add Specific Subgroup Decorators*/ $this->getSubForm('login_with_password')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with password') ) )); $this->getSubForm('login_with_captcha')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with captcha') ) )); /*Set form specific elements Decorators*/ $this->getSubForm('login_with_captcha')->getElement('captcha')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('login')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('password')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('remember_me')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); /*Set form commons elements Decorators*/ $this->setElementDecorators(array( array('ViewHelper'), //array('Errors'), //array('Description', array('tag' => 'p', 'class' => 'description')), //array('HtmlTag', array('tag' => 'dd')), //array('Label', array('tag' => 'dt')), //array('Label', array('tag' => 'dl')), ) ); } }
et j'ai même cette balise dd qui traine encore ! C'est quoi ce bordel ?
authentication<fieldset id="fieldset-login_with_password" class="fixed"><legend>login with password</legend> <label for="login" class="fixed required">Login name :</label> <dd id="login-element"> <input type="text" name="login_with_password[login]" id="login" value="" class="fixed"></dd> <label for="password" class="fixed required">Secret password :</label> <dd id="password-element"> <input type="password" name="login_with_password[password]" id="password" value="" class="fixed"></dd> <label for="remember_me" class="fixed optional">Remember me :</label> <dd id="remember_me-element"> <input type="hidden" name="login_with_password[remember_me]" value="0"><input type="checkbox" name="login_with_password[remember_me]" id="remember_me" value="1" class="fixed"></dd></fieldset><fieldset id="fieldset-login_with_captcha" class="fixed"><legend>login with captcha</legend> <label for="login_with_captcha[captcha]-input" class="fixed required">5 letters displayed :</label> <dd> <img width="106" height="35" alt="" src="/img/captcha/85cbe1623f89136a76446c244ed18a9b.png"/><br/> <input type="hidden" name="login_with_captcha[captcha][id]" value="85cbe1623f89136a76446c244ed18a9b" class="fixed" id="login_with_captcha-captcha-id"> <input type="text" name="login_with_captcha[captcha][input]" id="login_with_captcha-captcha-input" value="" class="fixed"></dd></fieldset>
Bon je vais aller faire un tour moi ... histoire de me calmer !
Dernière modification par daverck (18-09-2009 15:23:23)
Hors ligne
Juste pour savoir, comment tu effectues le rendu de ton formulaire dans ta vue ?
Hors ligne
echo $this->_formLoginGuest->getSubForm('login_with_password') . $this->_formLoginGuest->getSubForm('login_with_captcha');
oui effectivement ça semble venir de là
si je fais
echo $this->_formLoginGuest;
là par contre j'ai une erreur
authentication<br /> <b>Warning</b>: Illegal offset type in <b>/home/daverck/Programmation/sites/ZendFramework/trunk/library/Zend/Form.php</b> on line <b>3002</b><br /> <br /> <b>Warning</b>: Illegal offset type in <b>/home/daverck/Programmation/sites/ZendFramework/trunk/library/Zend/Form.php</b> on line <b>3002</b><br /> <form id="login_guest_form" enctype="application/x-www-form-urlencoded" action="index" method="post"><div class="fixed"> <input type="submit" name="submit_login_guest" id="submit_login_guest" value="OK" class="fixed"> <input type="hidden" name="csrf_login_guest" value="624f795b53a24304ed3e70702ffe4266" id="csrf_login_guest"></div></form>
mais tu as raison, je vais creuser ça !
(ça n'a pas l'air simple !)
Hors ligne
OK !! Tout est correct
c'est du à quelques mauvais type de paramètre (le troisième argument de addSubform est un entier)
merci à tous (aelyta1 et nORKy) ça soulage d'arriver à quelque chose !
:-)
PS. d'accord j'ai un bouton correct mais "les dd sont toujours là" :
mon formulaire
<?php class Default_Form_LoginGuest extends Zend_Form { public function init() { // Set the method for the form to POST $this->setDescription('formulaire de login') ->setEnctype(Zend_Form::ENCTYPE_URLENCODED) ->setLegend('login') ->setName("login_guest_form") ->setAction('index') ->setMethod('post'); // Create Subforms $login_with_password = new Zend_Form_SubForm(); $login_with_captcha = new Zend_Form_SubForm(); // Association of subform with the form : $this->addSubForm($login_with_captcha, 'login_with_captcha', 0 ); $this->addSubform($login_with_password, 'login_with_password', 1 ); // Add a submit button $this->addElement('submit', 'submit_login_guest', array( 'ignore' => true, 'label' => 'OK', 'class' => 'fixed' //'description' => 'Clic here to validate the authentication' ) ); // And finally add some CSRF protection $this->addElement('hash', 'csrf_login_guest', array( 'ignore' => true ) ); // Add a login element $login_with_password->addElement('text', 'login', array( 'label' => 'Login name :', 'required' => true, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your login name', 'id' => 'login', 'class' => 'fixed' ) ); // Add a password element $login_with_password->addElement('password', 'password', array( 'label' => 'Secret password :', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), 'ErrorMessages' => array('required'=>'Element requis'), //'description' => 'Enter your secret password', 'id' => 'password', 'class' => 'fixed' ) ); $login_with_password->addElement('checkbox', 'remember_me', array( 'label' => 'Remember me :', 'required' => false, //'description' => 'Remeber your login and password ?', 'id' => 'remember_me', 'class' => 'fixed' ) ); // Add a captcha $login_with_captcha->addElement('captcha', 'captcha', array( 'label' => '5 letters displayed :', //'description' => 'Enter the captcha below for anonymous surfing', 'class' => 'fixed', 'required' => true, 'validators' => array(array('StringLength', false, array(5, 5))), 'ErrorMessages' => array('required'=>'Element requis'), 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 5, 'timeout' => 300, 'width' => 106, 'height' => 35, 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 3, 'font' => APPLICATION_PATH . '/../public/fonts/arial.ttf', 'fontSize' => 25, 'imgDir' => APPLICATION_PATH . '/../public/img/captcha/', 'imgUrl' => '/img/captcha/', ) ) ); /*#######################################*/ /*###### Here comes the decorators ######*/ /*#######################################*/ /*Set form Decorators*/ $this->setDecorators(array( array('FormElements'), array('HtmlTag', array('tag' => 'div','class' => 'fixed')), array('Form') ) ); /*Set subform Decorators*/ $this->setSubFormDecorators(array( array('FormElements') ) ); /*Add Specific Subgroup Decorators*/ $this->getSubForm('login_with_password')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with password') ) )); $this->getSubForm('login_with_captcha')->addDecorators(array( array('Fieldset', array('class' => 'fixed', 'legend' => 'login with captcha') ) )); /*Set form specific elements Decorators*/ $this->getSubForm('login_with_captcha')->getElement('captcha')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('login')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('password')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); $this->getSubForm('login_with_password')->getElement('remember_me')->addDecorators(array( array('Label', array('class' => 'fixed')) ) ); /*Set form commons elements Decorators*/ $this->setElementDecorators(array( array('ViewHelper'), ), null, null ); } }
mon html :
authentication<form id="login_guest_form" enctype="application/x-www-form-urlencoded" action="index" method="post"><div class="fixed"> <fieldset id="fieldset-login_with_captcha" class="fixed"><legend>login with captcha</legend> <label for="login_with_captcha[captcha]-input" class="fixed required">5 letters displayed :</label> <dd> <img width="106" height="35" alt="" src="/img/captcha/511306b754570dfeca9ec17daf40af62.png"/><br/> <input type="hidden" name="login_with_captcha[captcha][id]" value="511306b754570dfeca9ec17daf40af62" class="fixed" id="login_with_captcha-captcha-id"> <input type="text" name="login_with_captcha[captcha][input]" id="login_with_captcha-captcha-input" value="" class="fixed"></dd></fieldset> <fieldset id="fieldset-login_with_password" class="fixed"><legend>login with password</legend> <label for="login" class="fixed required">Login name :</label> <dd id="login-element"> <input type="text" name="login_with_password[login]" id="login" value="" class="fixed"></dd> <label for="password" class="fixed required">Secret password :</label> <dd id="password-element"> <input type="password" name="login_with_password[password]" id="password" value="" class="fixed"></dd> <label for="remember_me" class="fixed optional">Remember me :</label> <dd id="remember_me-element"> <input type="hidden" name="login_with_password[remember_me]" value="0"><input type="checkbox" name="login_with_password[remember_me]" id="remember_me" value="1" class="fixed"></dd></fieldset> <input type="submit" name="submit_login_guest" id="submit_login_guest" value="OK" class="fixed"> <input type="hidden" name="csrf_login_guest" value="36ffd81b78e099d48101125366e4ea4e" id="csrf_login_guest"></div></form>
Je sais que je devrais peut-être faire un autre fil mais comme c'est le sujet de départ ... on pourrait continuer dessus non ?
Dernière modification par daverck (18-09-2009 18:30:15)
Hors ligne
Dans ton init(), tu peux faire appel à $this->setDisableLoadDefaultDecorators(true) pour désactiver les décorateurs par défaut.
Ou alors, utilise setDecorators au lieu de Add (pour faire remplacé ceux existant)
Hors ligne
Pages: 1