Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
j'essai de faire un decorator qui me permettrais de mettre mon formulaire dans un table de cette maniere :
<table> <tr> <td> <label class="required" for="candidats_nom">Nom :</label> </td> <td> <input type="text" value="" id="candidats_nom" name="candidats_nom"/> </td> <td> <label class="required" for="candidats_prenom">Prénom :</label> </td> <td> <input type="text" value="" id="candidats_prenom" name="candidats_prenom"/> </td> </tr> </table>
je n'y arrive que dans ce sens le :
<table> <tr> <td> <label class="required" for="candidats_nom">Nom :</label> </td> <td> <input type="text" value="" id="candidats_nom" name="candidats_nom"/> </td> </tr> <tr> <td> <label class="required" for="candidats_prenom">Prénom :</label> </td> <td> <input type="text" value="" id="candidats_prenom" name="candidats_prenom"/> </td> </tr> </table>
Dernière modification par jfrag (07-12-2009 11:24:19)
Hors ligne
Tu peux nous montrer la partie intéressante de ton code ?
Sinon en gros, tu mets un décorateur HtmlTag "table" et un autre "tr" sur l'instance Zend_Form. Ensuite tu met un décorateur HtmlTag "td", "Label", "td", et ViewHelper sur les éléments.
On y arriverait mieux avec le code
Hors ligne
J'ai essayé ce que tu m'a dis mais ca ne me mets meme pas le table :
formulaire : $this->setDecorators(array( 'FormElements', array('table' =>'HtmlTag', array('tag' => 'table')), array('tr'=>'HtmlTag', array('tag' => 'tr')), 'Form', )); decorateur d'elements : $elementDecorators = array( 'ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), );
Hors ligne
J'ai trouvé !!
Il ne suffit pas d'ajouter des decorators !!! il faut faire des displayGroup et leurs balancé un decorator chacun.
pour avoir ce rendu :
<form enctype="application/x-www-form-urlencoded" action="/candidats/add/" method="post"> <table> <tr> <td id="candidats_nom-label"> <label for="candidats_nom" class="required">Nom :</label> </td> <td> <input type="text" name="candidats_nom" id="candidats_nom" value="" /> </td> <td id="candidats_prenom-label"> <label for="candidats_prenom" class="required">Prénom :</label> </td> <td> <input type="text" name="candidats_prenom" id="candidats_prenom" value="" /> </td> </tr> <tr> <td id="candidats_poste-label"> <label for="candidats_poste" class="required">Poste :</label> </td> <td> <input type="text" name="candidats_poste" id="candidats_poste" value="" /> </td> <td id="candidats_date_naissance-label"> <label for="candidats_date_naissance" class="optional">Date de naissance:</label> </td> <td> <input type="text" name="candidats_date_naissance" id="candidats_date_naissance" value="" readonly="readonly" /> </td> </tr> </table> </form>
il faut :
Assigner ce decorators au formulaire : $this->setDecorators(array( 'FormElements', array(array('table'=>'HtmlTag'), array('tag' => 'table')), 'Form', )); Assigner ce decorators aux elements : $elementDecorators = array( 'ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('label', array('tag' => 'td')), ); Créer un display group : $this->addElements(array($nom, $prenom)); $this->addDisplayGroup(array('candidats_nom', 'candidats_prenom'), 'nom_prenom'); Assigner ce decorator au group: $this->getDisplayGroup('nom_prenom') ->setDecorators(array( 'FormElements', array('HtmlTag',array('tag'=>'tr')) ));
voila pour toute question n'hésitez pas !
Hors ligne