1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Attributes extends Mage_Adminhtml_Block_Catalog_Form
35: {
36: protected function _prepareForm()
37: {
38:
39: $form = new Varien_Data_Form();
40: 41: 42: 43:
44: $form->setDataObject(Mage::registry('product'));
45:
46: $fieldset = $form->addFieldset('group_fields', array());
47:
48: $attributes = $this->getGroupAttributes();
49:
50: $this->_setFieldset($attributes, $fieldset, array('gallery'));
51:
52: $values = Mage::registry('product')->getData();
53: 54: 55:
56: if (!Mage::registry('product')->getId()) {
57: foreach ($attributes as $attribute) {
58: if (!isset($values[$attribute->getAttributeCode()])) {
59: $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
60: }
61: }
62: }
63:
64: Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
65: $form->addValues($values);
66: $form->setFieldNameSuffix('product');
67: $this->setForm($form);
68: }
69:
70: protected function _getAdditionalElementTypes()
71: {
72: $result = array(
73: 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
74: 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
75: 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')
76: );
77:
78: $response = new Varien_Object();
79: $response->setTypes(array());
80: Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response'=>$response));
81:
82: foreach ($response->getTypes() as $typeName=>$typeClass) {
83: $result[$typeName] = $typeClass;
84: }
85:
86: return $result;
87: }
88:
89: protected function _toHtml()
90: {
91: parent::_toHtml();
92: return $this->getForm()->getElement('group_fields')->getChildrenHtml();
93: }
94: }
95: