Witam. Pewnie sprawa jest banalna, ale proszę o pomoc, utknąłem i nie mogę sobie poradzić. Mam w formularzu dwa inputy, które chciałbym wrzucić w tabelę:
  1. $e1 = new Zend_Form_Element_Text('e1');
  2. $e1
  3. ->setName('e')
  4. ->setAttrib('id', 'e1')
  5. ->addDecorators(array(
  6. 'decorator' => array('table' => 'HtmlTag'),
  7. 'options' => array('tag' => 'table', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND)
  8. )
  9. ,
  10. 'decorator' => array('td' => 'HtmlTag'),
  11. 'options' => array('tag' => 'td')
  12. )
  13. ,
  14. 'decorator' => array('tr' => 'HtmlTag'),
  15. 'options' => array('tag' => 'tr', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND))
  16. )
  17. );
  18.  
  19. $this->addElement($e1);
  20.  
  21. $e2 = new Zend_Form_Element_Text('e2');
  22. $e2
  23. ->setName('e2')
  24. ->setAttrib('id', 'e2')
  25. ->addDecorators(array(
  26. 'decorator' => array('table' => 'HtmlTag'),
  27. 'options' => array('tag' => 'table', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)
  28. )
  29. ,
  30. 'decorator' => array('td' => 'HtmlTag'),
  31. 'options' => array('tag' => 'td')
  32. )
  33. ,
  34. 'decorator' => array('tr' => 'HtmlTag'),
  35. 'options' => array('tag' => 'tr', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND))
  36. )
  37. );
  38.  
  39. $this->addElement($e2);

Efekt:
  1. <tr><td><table><dt id="e1-label">&nbsp;</dt>
  2. <dd id="e1-element">
  3. <input type="text" name="e1" id="e1" value=""/></dd></td>
  4. <td><dt id="e1-label">&nbsp;</dt>
  5. <dd id="e2-element">
  6. <input type="text" name="e2" id="e2" value="" /></dd></table></td></tr>

Jak zrobić, żeby tagi <table></table> były we właściwych miejscach, czyli jedyny pożądany efekt, to:
  1. <table><tr><td><dt id="e1-label">&nbsp;</dt>
  2. <dd id="e1-element">
  3. <input type="text" name="e1" id="e1" value=""/></dd></td>
  4. <td><dt id="e1-label">&nbsp;</dt>
  5. <dd id="e2-element">
  6. <input type="text" name="e2" id="e2" value="" /></dd></td></tr></table>

?
Dodam, że jeżeli zmienię kolejność dekoratorów w ten sposób:
  1. $e1 = new Zend_Form_Element_Text('e1');
  2. $e1
  3. ->setName('e')
  4. ->setAttrib('id', 'e1')
  5. ->addDecorators(array(
  6. 'decorator' => array('td' => 'HtmlTag'),
  7. 'options' => array('tag' => 'td')
  8. )
  9. ,
  10. 'decorator' => array('tr' => 'HtmlTag'),
  11. 'options' => array('tag' => 'tr', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND))
  12. )
  13. ,
  14. 'decorator' => array('table' => 'HtmlTag'),
  15. 'options' => array('tag' => 'table', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND)
  16. )
  17. );
  18.  
  19. $this->addElement($e1);
  20.  
  21. $e2 = new Zend_Form_Element_Text('e2');
  22. $e2
  23. ->setName('e2')
  24. ->setAttrib('id', 'e2')
  25. ->addDecorators(array(
  26. 'decorator' => array('td' => 'HtmlTag'),
  27. 'options' => array('tag' => 'td')
  28. )
  29. ,
  30. 'decorator' => array('tr' => 'HtmlTag'),
  31. 'options' => array('tag' => 'tr', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND))
  32. )
  33. ,
  34. 'decorator' => array('table' => 'HtmlTag'),
  35. 'options' => array('tag' => 'table', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)
  36. )
  37. );
  38.  
  39. $this->addElement($e2);

to w ogóle <table> i </table> się nie pojawią. Co robię źle ?

Właściwie chodzi mi o objęcie tabelą pewnej grupy elementów, która jest już objęta divem:
$step4 = array('el1', 'el2', 'el3', 'el4');
$add_form->addDisplayGroup($step4, 'step4');
$add_form->getDisplayGroup('step4')->addDecorator('HtmlTag', array('tag' => 'div', 'id'=>'step4'));
Próbowałem tak:
  1. $add_form->getDisplayGroup('step4')->setDecorators(
  2. 'FormElements',
  3. array('HtmlTag', array('tag' => 'table')),
  4. 'Form'
  5. )
  6. );

Niestety tabela nadpisuje tag <div>. Próbowałem tak:

  1. $add_form->getDisplayGroup('step4')->addDecorators(array('tag' => 'div', 'id'=>'step4'), array('HtmlTag', array('tag' => 'table')));

i...
Cytat
Warning: Exception caught by form: Plugin by name 'Div' was not found in the registry;


Powyższy problem dotyczy formularza wymienionego w tym temacie

anyone questionmark.gif

ROZWIĄZANE - hidden i label z wyłączonym dekoratorem escape