/** * Add rendering EAV attributes to Form element * * @param array|Varien_Data_Collection $attributes * @param Varien_Data_Form_Abstract $form * @return Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract */ protected function _addAttributesToForm($attributes, Varien_Data_Form_Abstract $form) { // add additional form types $types = $this->_getAdditionalFormElementTypes(); foreach ($types as $type => $className) { $form->addType($type, $className); } $renderers = $this->_getAdditionalFormElementRenderers(); foreach ($attributes as $attribute) { /** @var $attribute Mage_Customer_Model_Attribute */ $attribute->setStoreId(Mage::getSingleton('adminhtml/session_quote')->getStoreId()); $inputType = $attribute->getFrontend()->getInputType(); if ($inputType) { $element = $form->addField($attribute->getAttributeCode(), $inputType, array('name' => $attribute->getAttributeCode(), 'label' => $this->__($attribute->getStoreLabel()), 'class' => $attribute->getFrontend()->getClass(), 'required' => $attribute->getIsRequired())); if ($inputType == 'multiline') { $element->setLineCount($attribute->getMultilineCount()); } $element->setEntityAttribute($attribute); $this->_addAdditionalFormElementData($element); if (!empty($renderers[$attribute->getAttributeCode()])) { $element->setRenderer($renderers[$attribute->getAttributeCode()]); } if ($inputType == 'select' || $inputType == 'multiselect') { $element->setValues($attribute->getFrontend()->getSelectOptions()); } else { if ($inputType == 'date') { $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $element->setImage($this->getSkinUrl('images/grid-cal.gif')); $element->setFormat($format); } } } } return $this; }
/** * Add new element type * * @param Varien_Data_Form_Abstract $baseElement */ protected function _addElementTypes(Varien_Data_Form_Abstract $baseElement) { $types = $this->_getAdditionalElementTypes(); foreach ($types as $code => $className) { $baseElement->addType($code, $className); } }