AddShowStyle.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class Application_Form_AddShowStyle extends Zend_Form_SubForm
  3. {
  4. public function init()
  5. {
  6. // Add show background-color input
  7. $this->addElement('text', 'add_show_background_color', array(
  8. 'label' => _('Background Colour:'),
  9. 'class' => 'input_text',
  10. 'filters' => array('StringTrim')
  11. ));
  12. $bg = $this->getElement('add_show_background_color');
  13. $bg->setDecorators(array(array('ViewScript', array(
  14. 'viewScript' => 'form/add-show-style.phtml',
  15. 'class' => 'big'
  16. ))));
  17. $stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 6);
  18. $bg->setValidators(array(
  19. 'Hex', $stringLengthValidator
  20. ));
  21. // Add show color input
  22. $this->addElement('text', 'add_show_color', array(
  23. 'label' => _('Text Colour:'),
  24. 'class' => 'input_text',
  25. 'filters' => array('StringTrim')
  26. ));
  27. $c = $this->getElement('add_show_color');
  28. $c->setDecorators(array(array('ViewScript', array(
  29. 'viewScript' => 'form/add-show-style.phtml',
  30. 'class' => 'big'
  31. ))));
  32. $c->setValidators(array(
  33. 'Hex', $stringLengthValidator
  34. ));
  35. }
  36. public function disable()
  37. {
  38. $elements = $this->getElements();
  39. foreach ($elements as $element) {
  40. if ($element->getType() != 'Zend_Form_Element_Hidden') {
  41. $element->setAttrib('disabled','disabled');
  42. }
  43. }
  44. }
  45. }