Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
J'ai étendu Zend_Form et Subform pour rédéfinir mes décorateurs, tout a bien pour les éléments dans un form et dans un displaygroup. Mais dans un subform ça me garde les dt dd .
<?php class Dis_Form extends Zend_Form { public function loadDefaultDecorators() { $this->setDecorators(array( 'FormElements', 'Form', )); //Set decorators for the displaygroup: $this->setDisplayGroupDecorators(array( 'FormElements', array(array('ulwrap' => 'HtmlTag'), array('tag' => 'ul')), //this adds a <ul> inside the <form> 'Fieldset', )); //Set the decorators we need: $this->setElementDecorators(array( 'ViewHelper', 'Label', 'Errors', new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap elements in <li>'s )); $this->setSubFormDecorators(array( 'FormElements', array(array('ulwrap' => 'HtmlTag'), array('tag' => 'ul')), //this adds a <ul> inside the <form> 'Fieldset', )); $elements = $this->getElements(); foreach ($elements as $element) { if($element instanceof Zend_Form_Element_Submit) { $element ->setDecorators(array( 'ViewHelper', new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap elements in <li>'s )); } } } }
<?php class Dis_Form_SubForm extends Dis_Form { public function loadDefaultDecorators() { $this->setElementDecorators(array( 'ViewHelper', 'Label', 'Errors', new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap elements in <li>'s )); } }
Même si je ne définis pas public function loadDefaultDecorators() pour Dis_Form_Subform j'ai le même résultat.
Quelqu'un a une idée ? :s
Hors ligne
Petite réponse à moi même si ça peut en aider, il faut également redéfinir la méthode render() apperement :
public function render(Zend_View_Interface $view = null) { $this->setSubFormDecorators(array( 'FormElements', array(array('ulwrap' => 'HtmlTag'), array('tag' => 'ul')), //this adds a <ul> inside the <form> 'Fieldset', )); // walk subforms recursively using stack and set decorators to them $stack = array($this); while (!empty($stack)) { $form = array_pop($stack); //Set decorators for the displaygroup: $form->setDisplayGroupDecorators(array( 'FormElements', array(array('ulwrap' => 'HtmlTag'), array('tag' => 'ul')), //this adds a <ul> inside the <form> 'Fieldset', )); //Set the decorators we need: $form->setElementDecorators(array( 'ViewHelper', 'Label', 'Errors', new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap elements in <li>'s )); foreach ($form->getSubForms() as $subForm) { $stack[] = $subForm; } } return parent::render($view); }
Hors ligne