Guest User

Untitled

a guest
Apr 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. function loadDefaultDecorators()
  2. {
  3. parent::loadDefaultDecorators();
  4. $this->setDecorators( array( 'FormElements', 'form' ) );
  5. $this->setElementDecorators( array(
  6. 'Description',
  7. 'ViewHelper',
  8. 'Errors',
  9. array( array( 'row' => 'HtmlTag' ), array( 'tag' => 'div' ) )
  10. ) );
  11.  
  12. $subForms = $this->getSubForms();
  13. foreach ( $subForms as $subForm )
  14. {
  15. $subForm->setDecorators( array(
  16. 'FormElements',
  17. array('HtmlTag', array('tag' => 'table', 'class' => 'standart')),
  18. 'Fieldset'
  19. ) );
  20. $subelements = $subForm->getElements();
  21. foreach ( $subelements as $subelement )
  22. {
  23. $subelement->setDecorators( array(
  24. 'ViewHelper',
  25. 'Errors',
  26.  
  27. array( array( 'data' => 'HtmlTag' ), array( 'tag' => 'td', 'class' => 'element' ) ),
  28. array( 'Label', array( 'tag' => 'td' ) ),
  29. array( 'Description', array( 'tag' => 'td' ) ),
  30. array( array( 'row' => 'HtmlTag' ), array( 'tag' => 'tr' ) ),
  31. ) );
  32. }
  33. }
  34.  
  35. $elements = $this->getElements();
  36. foreach ( $elements as $element )
  37. {
  38. // элементы-кнопки в label не нуждаются
  39. if ( 'Zend_Form_Element_Submit' == $element->getType() )
  40. {
  41. $element->setDecorators( array(
  42. 'ViewHelper',
  43. 'Description',
  44. 'Errors',
  45. array( array( 'row' => 'HtmlTag' ), array( 'tag' => 'div' ) )
  46. ) );
  47. }
  48.  
  49. if ( 'Zend_Form_Element_Checkbox' == $element->getType() )
  50. {
  51. $element->setDecorators( array(
  52. 'ViewHelper',
  53. 'Description',
  54. 'Errors',
  55. array( 'Label', array( 'placement' => 'append' ) ),
  56. array( array( 'row' => 'HtmlTag' ), array( 'tag' => 'div' ) )
  57. ) );
  58. }
  59.  
  60. //спрятанные элементы вообще не нуждаются в декораторах, помимо самого элемента
  61. if ( 'Zend_Form_Element_Hidden' == $element->getType() )
  62. {
  63. $element->setDecorators( array(
  64. 'ViewHelper',
  65. ) );
  66. }
  67. }
  68.  
  69. return $this;
  70. }
Add Comment
Please, Sign In to add comment