Protected Member Functions | |
_prepareForm () | |
_getAdditionalElementTypes () |
Definition at line 35 of file Main.php.
_getAdditionalElementTypes | ( | ) | [protected] |
Retrieve predefined additional element types
Reimplemented from Mage_Adminhtml_Block_Widget_Form.
Definition at line 402 of file Main.php.
00403 { 00404 return array( 00405 'apply' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_apply') 00406 ); 00407 }
_prepareForm | ( | ) | [protected] |
Prepare form before rendering HTML
Reimplemented from Mage_Adminhtml_Block_Widget_Form.
Definition at line 38 of file Main.php.
00039 { 00040 $model = Mage::registry('entity_attribute'); 00041 00042 $form = new Varien_Data_Form(array( 00043 'id' => 'edit_form', 00044 'action' => $this->getData('action'), 00045 'method' => 'post' 00046 )); 00047 00048 $disableAttributeFields = array( 00049 'sku' => array( 00050 'is_global', 00051 'is_unique', 00052 ), 00053 'url_key' => array( 00054 'is_unique', 00055 ), 00056 ); 00057 00058 $fieldset = $form->addFieldset('base_fieldset', 00059 array('legend'=>Mage::helper('catalog')->__('Attribute Properties')) 00060 ); 00061 if ($model->getAttributeId()) { 00062 $fieldset->addField('attribute_id', 'hidden', array( 00063 'name' => 'attribute_id', 00064 )); 00065 } 00066 00067 $this->_addElementTypes($fieldset); 00068 00069 $yesno = array( 00070 array( 00071 'value' => 0, 00072 'label' => Mage::helper('catalog')->__('No') 00073 ), 00074 array( 00075 'value' => 1, 00076 'label' => Mage::helper('catalog')->__('Yes') 00077 )); 00078 00079 $fieldset->addField('attribute_code', 'text', array( 00080 'name' => 'attribute_code', 00081 'label' => Mage::helper('catalog')->__('Attribute Code'), 00082 'title' => Mage::helper('catalog')->__('Attribute Code'), 00083 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 00084 'class' => 'validate-code', 00085 'required' => true, 00086 )); 00087 00088 $scopes = array( 00089 Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'), 00090 Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'), 00091 Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'), 00092 ); 00093 00094 if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { 00095 unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); 00096 } 00097 00098 $fieldset->addField('is_global', 'select', array( 00099 'name' => 'is_global', 00100 'label' => Mage::helper('catalog')->__('Scope'), 00101 'title' => Mage::helper('catalog')->__('Scope'), 00102 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 00103 'values'=> $scopes 00104 )); 00105 00106 $inputTypes = array( 00107 array( 00108 'value' => 'text', 00109 'label' => Mage::helper('catalog')->__('Text Field') 00110 ), 00111 array( 00112 'value' => 'textarea', 00113 'label' => Mage::helper('catalog')->__('Text Area') 00114 ), 00115 array( 00116 'value' => 'date', 00117 'label' => Mage::helper('catalog')->__('Date') 00118 ), 00119 array( 00120 'value' => 'boolean', 00121 'label' => Mage::helper('catalog')->__('Yes/No') 00122 ), 00123 array( 00124 'value' => 'multiselect', 00125 'label' => Mage::helper('catalog')->__('Multiple Select') 00126 ), 00127 array( 00128 'value' => 'select', 00129 'label' => Mage::helper('catalog')->__('Dropdown') 00130 ), 00131 array( 00132 'value' => 'price', 00133 'label' => Mage::helper('catalog')->__('Price') 00134 ), 00135 array( 00136 'value' => 'gallery', 00137 'label' => Mage::helper('catalog')->__('Gallery') 00138 ), 00139 array( 00140 'value' => 'media_image', 00141 'label' => Mage::helper('catalog')->__('Media Image') 00142 ), 00143 ); 00144 00145 $response = new Varien_Object(); 00146 $response->setTypes(array()); 00147 Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); 00148 00149 $_disabledTypes = array(); 00150 $_hiddenFields = array(); 00151 foreach ($response->getTypes() as $type) { 00152 $inputTypes[] = $type; 00153 if (isset($type['hide_fields'])) { 00154 $_hiddenFields[$type['value']] = $type['hide_fields']; 00155 } 00156 if (isset($type['disabled_types'])) { 00157 $_disabledTypes[$type['value']] = $type['disabled_types']; 00158 } 00159 } 00160 Mage::register('attribute_type_hidden_fields', $_hiddenFields); 00161 Mage::register('attribute_type_disabled_types', $_disabledTypes); 00162 00163 00164 $fieldset->addField('frontend_input', 'select', array( 00165 'name' => 'frontend_input', 00166 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 00167 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 00168 'value' => 'text', 00169 'values'=> $inputTypes 00170 )); 00171 00172 $fieldset->addField('default_value_text', 'text', array( 00173 'name' => 'default_value_text', 00174 'label' => Mage::helper('catalog')->__('Default value'), 00175 'title' => Mage::helper('catalog')->__('Default value'), 00176 'value' => $model->getDefaultValue(), 00177 )); 00178 00179 $fieldset->addField('default_value_yesno', 'select', array( 00180 'name' => 'default_value_yesno', 00181 'label' => Mage::helper('catalog')->__('Default value'), 00182 'title' => Mage::helper('catalog')->__('Default value'), 00183 'values' => $yesno, 00184 'value' => $model->getDefaultValue(), 00185 )); 00186 00187 $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); 00188 $fieldset->addField('default_value_date', 'date', array( 00189 'name' => 'default_value_date', 00190 'label' => Mage::helper('catalog')->__('Default value'), 00191 'title' => Mage::helper('catalog')->__('Default value'), 00192 'image' => $this->getSkinUrl('images/grid-cal.gif'), 00193 'value' => $model->getDefaultValue(), 00194 'format' => $dateFormatIso 00195 )); 00196 00197 $fieldset->addField('default_value_textarea', 'textarea', array( 00198 'name' => 'default_value_textarea', 00199 'label' => Mage::helper('catalog')->__('Default value'), 00200 'title' => Mage::helper('catalog')->__('Default value'), 00201 'value' => $model->getDefaultValue(), 00202 )); 00203 00204 $fieldset->addField('is_unique', 'select', array( 00205 'name' => 'is_unique', 00206 'label' => Mage::helper('catalog')->__('Unique Value'), 00207 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'), 00208 'note' => Mage::helper('catalog')->__('Not shared with other products'), 00209 'values' => $yesno, 00210 )); 00211 00212 $fieldset->addField('is_required', 'select', array( 00213 'name' => 'is_required', 00214 'label' => Mage::helper('catalog')->__('Values Required'), 00215 'title' => Mage::helper('catalog')->__('Values Required'), 00216 'values' => $yesno, 00217 )); 00218 00219 $fieldset->addField('frontend_class', 'select', array( 00220 'name' => 'frontend_class', 00221 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 00222 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 00223 'values'=> array( 00224 array( 00225 'value' => '', 00226 'label' => Mage::helper('catalog')->__('None') 00227 ), 00228 array( 00229 'value' => 'validate-number', 00230 'label' => Mage::helper('catalog')->__('Decimal Number') 00231 ), 00232 array( 00233 'value' => 'validate-digits', 00234 'label' => Mage::helper('catalog')->__('Integer Number') 00235 ), 00236 array( 00237 'value' => 'validate-email', 00238 'label' => Mage::helper('catalog')->__('Email') 00239 ), 00240 array( 00241 'value' => 'validate-url', 00242 'label' => Mage::helper('catalog')->__('Url') 00243 ), 00244 array( 00245 'value' => 'validate-alpha', 00246 'label' => Mage::helper('catalog')->__('Letters') 00247 ), 00248 array( 00249 'value' => 'validate-alphanum', 00250 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)') 00251 ), 00252 ) 00253 )); 00254 /* 00255 $fieldset->addField('use_in_super_product', 'select', array( 00256 'name' => 'use_in_super_product', 00257 'label' => Mage::helper('catalog')->__('Apply To Configurable/Grouped Product'), 00258 'values' => $yesno, 00259 )); */ 00260 00261 $fieldset->addField('apply_to', 'apply', array( 00262 'name' => 'apply_to[]', 00263 'label' => Mage::helper('catalog')->__('Apply To'), 00264 'values' => Mage_Catalog_Model_Product_Type::getOptions(), 00265 'mode_labels' => array( 00266 'all' => Mage::helper('catalog')->__('All Product Types'), 00267 'custom' => Mage::helper('catalog')->__('Selected Product Types') 00268 ), 00269 'required' => true 00270 )); 00271 00272 $fieldset->addField('is_configurable', 'select', array( 00273 'name' => 'is_configurable', 00274 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'), 00275 'values' => $yesno, 00276 )); 00277 // ----- 00278 00279 00280 // frontend properties fieldset 00281 $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties'))); 00282 00283 $fieldset->addField('is_searchable', 'select', array( 00284 'name' => 'is_searchable', 00285 'label' => Mage::helper('catalog')->__('Use in quick search'), 00286 'title' => Mage::helper('catalog')->__('Use in quick search'), 00287 'values' => $yesno, 00288 )); 00289 00290 $fieldset->addField('is_visible_in_advanced_search', 'select', array( 00291 'name' => 'is_visible_in_advanced_search', 00292 'label' => Mage::helper('catalog')->__('Use in advanced search'), 00293 'title' => Mage::helper('catalog')->__('Use in advanced search'), 00294 'values' => $yesno, 00295 )); 00296 00297 $fieldset->addField('is_comparable', 'select', array( 00298 'name' => 'is_comparable', 00299 'label' => Mage::helper('catalog')->__('Comparable on Front-end'), 00300 'title' => Mage::helper('catalog')->__('Comparable on Front-end'), 00301 'values' => $yesno, 00302 )); 00303 00304 00305 $fieldset->addField('is_filterable', 'select', array( 00306 'name' => 'is_filterable', 00307 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"), 00308 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 00309 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 00310 'values' => array( 00311 array('value' => '0', 'label' => Mage::helper('catalog')->__('No')), 00312 array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')), 00313 array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')), 00314 ), 00315 )); 00316 00317 $fieldset->addField('is_filterable_in_search', 'select', array( 00318 'name' => 'is_filterable_in_search', 00319 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"), 00320 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 00321 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 00322 'values' => $yesno, 00323 )); 00324 00325 $fieldset->addField('is_used_for_price_rules', 'select', array( 00326 'name' => 'is_used_for_price_rules', 00327 'label' => Mage::helper('catalog')->__('Use for Price Rule Conditions'), 00328 'title' => Mage::helper('catalog')->__('Use for Price Rule Conditions'), 00329 'values' => $yesno, 00330 )); 00331 00332 $fieldset->addField('position', 'text', array( 00333 'name' => 'position', 00334 'label' => Mage::helper('catalog')->__('Position'), 00335 'title' => Mage::helper('catalog')->__('Position In Layered Navigation'), 00336 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'), 00337 'class' => 'validate-digits', 00338 )); 00339 00340 $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array( 00341 'name' => 'is_html_allowed_on_front', 00342 'label' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'), 00343 'title' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'), 00344 'values' => $yesno, 00345 )); 00346 if (!$model->getId()) { 00347 $htmlAllowed->setValue(1); 00348 } 00349 00350 $fieldset->addField('is_visible_on_front', 'select', array( 00351 'name' => 'is_visible_on_front', 00352 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 00353 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 00354 'values' => $yesno, 00355 )); 00356 00357 $fieldset->addField('used_in_product_listing', 'select', array( 00358 'name' => 'used_in_product_listing', 00359 'label' => Mage::helper('catalog')->__('Used in product listing'), 00360 'title' => Mage::helper('catalog')->__('Used in product listing'), 00361 'note' => Mage::helper('catalog')->__('Depends on design theme'), 00362 'values' => $yesno, 00363 )); 00364 $fieldset->addField('used_for_sort_by', 'select', array( 00365 'name' => 'used_for_sort_by', 00366 'label' => Mage::helper('catalog')->__('Used for sorting in product listing'), 00367 'title' => Mage::helper('catalog')->__('Used for sorting in product listing'), 00368 'note' => Mage::helper('catalog')->__('Depends on design theme'), 00369 'values' => $yesno, 00370 )); 00371 00372 if ($model->getId()) { 00373 $form->getElement('attribute_code')->setDisabled(1); 00374 $form->getElement('frontend_input')->setDisabled(1); 00375 00376 if (isset($disableAttributeFields[$model->getAttributeCode()])) { 00377 foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { 00378 $form->getElement($field)->setDisabled(1); 00379 } 00380 } 00381 } 00382 if (!$model->getIsUserDefined() && $model->getId()) { 00383 $form->getElement('is_unique')->setDisabled(1); 00384 } 00385 00386 $form->addValues($model->getData()); 00387 00388 $form->getElement('apply_to')->setSize(5); 00389 00390 if ($applyTo = $model->getApplyTo()) { 00391 $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo); 00392 $form->getElement('apply_to')->setValue($applyTo); 00393 } else { 00394 $form->getElement('apply_to')->addClass('no-display ignore-validate'); 00395 } 00396 00397 $this->setForm($form); 00398 00399 return parent::_prepareForm(); 00400 }