Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes:

Mage_Adminhtml_Block_Catalog_Form Mage_Adminhtml_Block_Widget_Form Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes

List of all members.

Protected Member Functions

 _prepareForm ()
 _getAdditionalElementTypes ()


Detailed Description

Definition at line 34 of file Attributes.php.


Member Function Documentation

_getAdditionalElementTypes (  )  [protected]

Retrieve predefined additional element types

Returns:
array

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 114 of file Attributes.php.

00115     {
00116         $result = array(
00117             'price'   => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
00118             'gallery' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_gallery'),
00119             'image'   => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
00120             'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')
00121         );
00122 
00123         $response = new Varien_Object();
00124         $response->setTypes(array());
00125         Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response'=>$response));
00126 
00127         foreach ($response->getTypes() as $typeName=>$typeClass) {
00128             $result[$typeName] = $typeClass;
00129         }
00130 
00131         return $result;
00132     }

_prepareForm (  )  [protected]

Prepare form before rendering HTML

Returns:
Mage_Adminhtml_Block_Widget_Form

Initialize product object as form property for using it in elements generation

Add new attribute button if not image tab

Set attribute default values for new product

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Reimplemented in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple, and Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes.

Definition at line 36 of file Attributes.php.

00037     {
00038         if ($group = $this->getGroup()) {
00039             $form = new Varien_Data_Form();
00040             /**
00041              * Initialize product object as form property
00042              * for using it in elements generation
00043              */
00044             $form->setDataObject(Mage::registry('product'));
00045 
00046             $fieldset = $form->addFieldset('group_fields'.$group->getId(),
00047                 array('legend'=>Mage::helper('catalog')->__($group->getAttributeGroupName()))
00048             );
00049 
00050             $attributes = $this->getGroupAttributes();
00051 
00052             $this->_setFieldset($attributes, $fieldset, array('gallery'));
00053 
00054             if ($tierPrice = $form->getElement('tier_price')) {
00055                 $tierPrice->setRenderer(
00056                     $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
00057                 );
00058             }
00059 
00060             /**
00061              * Add new attribute button if not image tab
00062              */
00063             if (!$form->getElement('media_gallery')
00064                  && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
00065                 $headerBar = $this->getLayout()->createBlock(
00066                     'adminhtml/catalog_product_edit_tab_attributes_create'
00067                 );
00068 
00069                 $headerBar->getConfig()
00070                     ->setTabId('group_' . $group->getId())
00071                     ->setGroupId($group->getId())
00072                     ->setStoreId($form->getDataObject()->getStoreId())
00073                     ->setAttributeSetId($form->getDataObject()->getAttributeSetId())
00074                     ->setTypeId($form->getDataObject()->getTypeId())
00075                     ->setProductId($form->getDataObject()->getId());
00076 
00077                 $fieldset->setHeaderBar(
00078                     $headerBar->toHtml()
00079                 );
00080             }
00081 
00082             if ($form->getElement('meta_description')) {
00083                 $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
00084             }
00085 
00086             $values = Mage::registry('product')->getData();
00087             /**
00088              * Set attribute default values for new product
00089              */
00090             if (!Mage::registry('product')->getId()) {
00091                 foreach ($attributes as $attribute) {
00092                     if (!isset($values[$attribute->getAttributeCode()])) {
00093                         $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
00094                     }
00095                 }
00096             }
00097 
00098             if (Mage::registry('product')->hasLockedAttributes()) {
00099                 foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
00100                     if ($element = $form->getElement($attribute)) {
00101                         $element->setReadonly(true, true);
00102                     }
00103                 }
00104             }
00105 
00106             Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
00107 
00108             $form->addValues($values);
00109             $form->setFieldNameSuffix('product');
00110             $this->setForm($form);
00111         }
00112     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:44 2009 for Magento by  doxygen 1.5.8