2011-03-16 6 views
0

Je suis en train d'atteindre la sortie html suivant Zend_Form Décorateur:Zend Form Décorateur - ajout d'options pour étiquette d'une étiquette d'entrée

<tr> 
    <td id="from-label" **class="labelcell"**><label for="from" class="required">From</label></td> 
    <td><input type="text" name="from" id="from" value="" class="text"></td> 
</tr> 

J'essaie d'ajouter attribut de classe et par exemple attribut de style en ligne sur l'étiquette jointe de l'étiquette. Dans l'exemple ci-dessus, je veux ajouter class="labelcell "

Les déclarations de décorateur sont les suivantes:

$from = $this->createElement('text', 'from', array(
          'validators'=> array(array('regex', false, '/^[0-9]+/i')), 
          'required'=> true, 
          'label'=> 'From' 
         ) 
        ); 
     $from->setAttrib('class', 'text'); 
     $from->setDecorators(
       array(
       'ViewHelper', 
       'Description', 
       'Errors', 
       array(array('data'=>'HtmlTag'), array('tag' => 'td')), 
       array('Label', array('tag' => 'td')), 
       array(array('row' => 'HtmlTag'), array('tag' => 'tr')) 
       )); 

Est-il possible d'obtenir ce que je veux sans étendre la Zend_Form_Decorator_Label passer option supplémentaire à la balise englobante?

Répondre

1

il y a une option classe Vous devriez être en mesure de le définir dans votre tableau de configuration, trop Essayez ceci:..

$from->setDecorators(array(
    'ViewHelper', 
    'Description', 
    'Errors', 
    array(array('data'=>'HtmlTag'), array(
     'tag' => 'td' 
    )), 
    array('Label', array(
     'tag' => 'td', 
     'class' => 'labelcell' 
    )), 
    array(array('row' => 'HtmlTag'), array(
     'tag' => 'tr' 
    )), 
)); 
2
$from->setDecorators(array(
'ViewHelper', 
'Description', 
'Errors', 
array(array('data'=>'HtmlTag'), array(
    'tag' => 'td' 
)), 
array('Label', array(
    'tag' => 'td', 
    'class' => 'labelcell' 
    'tagClass' => 'YourClassNameHere' <- THIS IS WHAT WILL ADD TO LABEL WRAPPER 

)), 
array(array('row' => 'HtmlTag'), array(
    'tag' => 'tr' 
)), 

));

Questions connexes