/**
  * Add form element
  *
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $element
  * @param bool $after
  * @return Mage_XmlConnect_Model_Simplexml_Form
  */
 public function addElement(Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $element, $after = false)
 {
     if ($this->getForm()) {
         $this->getForm()->checkElementId($element->getId());
         $this->getForm()->addElementToCollection($element);
     }
     parent::addElement($element, $after);
     return $this;
 }
 /**
  * Add validator for file field to fieldset xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $fieldXmlObj
  * @return Mage_XmlConnect_Block_Customer_Form_Renderer_File
  */
 protected function _addValidator(Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $fieldXmlObj)
 {
     $validateRules = $this->getAttributeObject()->getValidateRules();
     if (!empty($validateRules)) {
         $validatorXmlObj = $fieldXmlObj->addValidator();
         if (!empty($validateRules['max_file_size'])) {
             $minTextLength = (int) $validateRules['max_file_size'];
             $validatorXmlObj->addRule(array('type' => 'max_file_size', 'value' => $minTextLength, 'field_label' => $this->getLabel()));
         }
         if (!empty($validateRules['file_extensions'])) {
             $maxTextLength = $validateRules['file_extensions'];
             $validatorXmlObj->addRule(array('type' => 'file_extensions', 'value' => $maxTextLength, 'field_label' => $this->getLabel()));
         }
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * Init multiline element
  *
  * @param array $attributes
  */
 public function __construct($attributes = array())
 {
     if (!isset($attributes['line_count'])) {
         Mage::throwException(Mage::helper('xmlconnect')->__('"line_count" attribute is required for "multiline" element.'));
     }
     parent::__construct($attributes);
     $this->setType('multiline');
 }
Esempio n. 4
0
 /**
  * Init validator rule element abstract
  *
  * @param array $attributes
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     $this->_renderer = Mage_XmlConnect_Model_Simplexml_Form::getValidatorRuleRenderer();
     $this->_setDefaultValidatorTypeMessages();
     if (isset($attributes['type'])) {
         $this->setType($attributes['type']);
     }
 }
Esempio n. 5
0
 /**
  * Init textarea element
  *
  * @param array $attributes
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     $this->setType('textarea');
 }
Esempio n. 6
0
 /**
  * Init checkbox element
  *
  * @param array $attributes
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     $this->setType('checkbox');
 }
Esempio n. 7
0
 /**
  * Add field element to fieldset
  *
  * @param string $elementId
  * @param string $type
  * @param array $config
  * @param boolean $after
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
  */
 public function addField($elementId, $type, $config, $after = false)
 {
     $element = parent::addField($elementId, $type, $config, $after);
     if ($renderer = Mage_XmlConnect_Model_Simplexml_Form::getFieldsetElementRenderer()) {
         $element->setRenderer($renderer);
     }
     return $element;
 }
Esempio n. 8
0
 /**
  * Add form element
  *
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $element
  * @param bool|string $after
  * @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
  */
 public function addElement(Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract $element, $after = false)
 {
     $element->setForm($this);
     $this->getElements()->add($element, $after);
     return $this;
 }
 /**
  * Init password element
  *
  * @param array $attributes
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     $this->setType('password');
 }