public function render(Varien_Object $row) { $row->setTypes(explode(',', $row->getTypes())); $out = ''; foreach (AW_Helpdesk3_Model_Source_Gateway_Mail_RejectPattern::toOptionArray() as $type) { if (in_array($type['value'], $row->getTypes())) { $out .= $type['label'] . '<br/>'; } } return $out; }
/** * Get product input types as option array * * @return array */ public function toOptionArray() { $inputTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image'))); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_product_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } if (Mage::registry('attribute_type_hidden_fields') === null) { Mage::register('attribute_type_hidden_fields', $_hiddenFields); } if (Mage::registry('attribute_type_disabled_types') === null) { Mage::register('attribute_type_disabled_types', $_disabledTypes); } return array_merge(parent::toOptionArray(), $inputTypes); }
protected function _prepareForm() { $model = Mage::registry('customerattributemanager_data'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $this->setForm($form); $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Attribute Properties'))); if ($model->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => $this->__('No')), array('value' => 1, 'label' => $this->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => $this->__('Attribute Code'), 'title' => $this->__('Attribute Code'), 'note' => $this->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => $this->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => $this->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => $this->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $inputTypes = array(array('value' => 'text', 'label' => $this->__('Text Field')), array('value' => 'textarea', 'label' => $this->__('Text Area')), array('value' => 'date', 'label' => $this->__('Date')), array('value' => 'boolean', 'label' => $this->__('Yes/No')), array('value' => 'multiselect', 'label' => $this->__('Multiple Select')), array('value' => 'select', 'label' => $this->__('Dropdown')), array('value' => 'file', 'label' => $this->__('File')), array('value' => 'image', 'label' => $this->__('Image'))); $response = new Varien_Object(); $response->setTypes(array()); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => $this->__('Input Type'), 'title' => $this->__('Input Type'), 'value' => 'text', 'values' => $inputTypes)); $fieldset->addField('default_value', 'select', array('name' => 'default_value', 'label' => $this->__('As WYSWYG'), 'title' => $this->__('As WYSWYG'), 'value' => 'text', 'values' => $yesno)); $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); $fieldset->addField('attribute_set_id', 'hidden', array('name' => 'attribute_set_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('attribute_group_id', 'hidden', array('name' => 'attribute_group_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('note', 'select', array('name' => 'note', 'label' => $this->__('Values Required'), 'title' => $this->__('Values Required'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => $this->__('Input Validation'), 'title' => $this->__('Input Validation'), 'values' => array(array('value' => '', 'label' => $this->__('None')), array('value' => 'validate-number', 'label' => $this->__('Decimal Number')), array('value' => 'validate-digits', 'label' => $this->__('Integer Number')), array('value' => 'validate-email', 'label' => $this->__('Email')), array('value' => 'validate-url', 'label' => $this->__('Url')), array('value' => 'validate-alpha', 'label' => $this->__('Letters')), array('value' => 'validate-alphanum', 'label' => $this->__('Letters(a-zA-Z) or Numbers(0-9)'))))); // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => $this->__('Frontend Properties'))); $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => $this->__('Order'), 'title' => $this->__('Order in form'), 'note' => $this->__('order of attribute in form edit/create. Leave blank for form bottom.'), 'class' => 'validate-digits', 'value' => $model->getSortOrder())); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } //var_dump($model->getData());exit; $form->addValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
protected function _getAdditionalElementTypes() { $result = array('price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'), 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'), 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response)); foreach ($response->getTypes() as $typeName => $typeClass) { $result[$typeName] = $typeClass; } return $result; }
protected function _getAdditionalElementTypes() { $result = array('price' => Mage::getConfig()->getBlockClassName('customgrid/widget_grid_form_helper_product_price'), 'gallery' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_gallery'), 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'), 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean'), 'textarea' => Mage::getConfig()->getBlockClassName('customgrid/widget_grid_form_helper_product_wysiwyg')); if ($this->helper('customgrid')->isMageVersionGreaterThan(1, 6)) { $result['weight'] = Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_weight'); } $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response)); foreach ($response->getTypes() as $typeName => $typeClass) { $result[$typeName] = $typeClass; } return $result; }
/** * Adding category form elements for editing attribute * * @return Hackathon_CatalogAttributes_Block_Adminhtml_Catalog_Category_Attribute_Edit_Tab_Main */ protected function _prepareForm() { parent::_prepareForm(); $attributeObject = $this->getAttributeObject(); /* @var $form Varien_Data_Form */ $form = $this->getForm(); /* @var $fieldset Varien_Data_Form_Element_Fieldset */ $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image'))); if ($attributeObject->getFrontendInput() == 'gallery') { $additionalTypes[] = array('value' => 'gallery', 'label' => Mage::helper('catalog')->__('Gallery')); } $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_category_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes), 'attribute_code'); // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('catalog')->__('Frontend Properties'))); $fieldset->addField('is_wysiwyg_enabled', 'select', array('name' => 'is_wysiwyg_enabled', 'label' => Mage::helper('catalog')->__('Enable WYSIWYG'), 'title' => Mage::helper('catalog')->__('Enable WYSIWYG'), 'values' => $yesnoSource)); $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array('name' => 'is_html_allowed_on_front', 'label' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'), 'title' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'), 'values' => $yesnoSource)); if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) { $attributeObject->setIsHtmlAllowedOnFront(1); } // define field dependencies $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')->addFieldMap("frontend_input", 'frontend_input_type')->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')); Mage::dispatchEvent('adminhtml_catalog_category_attribute_edit_prepare_form', array('form' => $form, 'attribute' => $attributeObject)); return $this; }
/** * Adding product form elements for editing attribute * * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main */ protected function _prepareForm() { parent::_prepareForm(); $attributeObject = $this->getAttributeObject(); /* @var $form Varien_Data_Form */ $form = $this->getForm(); /* @var $fieldset Varien_Data_Form_Element_Fieldset */ $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array(); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_customer_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); foreach ($frontendInputValues as $key => $_frontendInput) { if ($_frontendInput["value"] == 'multiselect') { unset($frontendInputValues[$key]); } } $frontendInputElm->setValues($frontendInputValues); $frontendInputElm->setLabel(Mage::helper("profile")->__("Input Type for Store Owner")); $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('profile')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('profile')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('profile')->__('Global')); if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('profile')->__('Scope'), 'title' => Mage::helper('profile')->__('Scope'), 'note' => Mage::helper('profile')->__('Declare attribute value saving scope'), 'values' => $scopes), 'attribute_code'); $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('profile')->__('Sort Order'), 'title' => Mage::helper('profile')->__('Sort Order'), 'note' => Mage::helper('profile')->__('This is the order according to which this field will display.'))); // frontend properties fieldset // define field dependencies $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')->addFieldMap("frontend_input", 'frontend_input_type')->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')); Mage::dispatchEvent('adminhtml_catalog_product_attribute_edit_prepare_form', array('form' => $form, 'attribute' => $attributeObject)); return $this; }
/** * Adding product form elements for editing attribute * * @access protected * @return Lionleap_Temples_Block_Adminhtml_Temple_Attribute_Edit_Tab_Main * @author Ultimate Module Creator */ protected function _prepareForm() { parent::_prepareForm(); $attributeObject = $this->getAttributeObject(); $form = $this->getForm(); $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array(array('value' => 'image', 'label' => Mage::helper('lionleap_temples')->__('Image')), array('value' => 'file', 'label' => Mage::helper('lionleap_temples')->__('File'))); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_temple_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('lionleap_temples')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('lionleap_temples')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('lionleap_temples')->__('Global')); $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('lionleap_temples')->__('Scope'), 'title' => Mage::helper('lionleap_temples')->__('Scope'), 'note' => Mage::helper('lionleap_temples')->__('Declare attribute value saving scope'), 'values' => $scopes), 'attribute_code'); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('lionleap_temples')->__('Position'), 'title' => Mage::helper('lionleap_temples')->__('Position'), 'note' => Mage::helper('lionleap_temples')->__('Position in the admin form')), 'is_global'); $fieldset->addField('note', 'textarea', array('name' => 'note', 'label' => Mage::helper('lionleap_temples')->__('Note'), 'title' => Mage::helper('lionleap_temples')->__('Note'), 'note' => Mage::helper('lionleap_temples')->__('Text to appear below the input.')), 'position'); $fieldset->removeField('is_unique'); // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('lionleap_temples')->__('Frontend Properties'))); $fieldset->addField('is_wysiwyg_enabled', 'select', array('name' => 'is_wysiwyg_enabled', 'label' => Mage::helper('lionleap_temples')->__('Enable WYSIWYG'), 'title' => Mage::helper('lionleap_temples')->__('Enable WYSIWYG'), 'values' => $yesnoSource)); Mage::dispatchEvent('lionleap_temples_adminhtml_temple_attribute_edit_prepare_form', array('form' => $form, 'attribute' => $attributeObject)); return $this; }
protected function _prepareForm() { $model = Mage::registry('attributemanager_data'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('catalog')->__('Attribute Properties'))); if ($model->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('catalog')->__('No')), array('value' => 1, 'label' => Mage::helper('catalog')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes)); $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('catalog')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('catalog')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('catalog')->__('Date')), array('value' => 'boolean', 'label' => Mage::helper('catalog')->__('Yes/No')), array('value' => 'multiselect', 'label' => Mage::helper('catalog')->__('Multiple Select')), array('value' => 'select', 'label' => Mage::helper('catalog')->__('Dropdown'))); $response = new Varien_Object(); $response->setTypes(array()); //Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); /****** champs cach�s dans le formulaire **********/ $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); $fieldset->addField('attribute_set_id', 'hidden', array('name' => 'attribute_set_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('attribute_group_id', 'hidden', array('name' => 'attribute_group_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); /*******************************************************/ $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('catalog')->__('Unique Value'), 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'), 'note' => Mage::helper('catalog')->__('Not shared with other products'), 'values' => $yesno)); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('is_visible', 'select', array('name' => 'is_visible', 'label' => Mage::helper('catalog')->__('Is Visible'), 'title' => Mage::helper('catalog')->__('Is Visible'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'values' => array(array('value' => '', 'label' => Mage::helper('catalog')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('catalog')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('catalog')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('catalog')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('catalog')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('catalog')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('catalog')->__('Frontend Properties'))); /* $fieldset->addField('position', 'text', array( 'name' => 'position', 'label' => Mage::helper('catalog')->__('Position'), 'title' => Mage::helper('catalog')->__('Position In Layered Navigation'), 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'), 'class' => 'validate-digits', ));*/ if ($model->getId()) { $write = Mage::getSingleton('core/resource')->getConnection('core_write'); $readresult = $write->query("SELECT * from customer_form_attribute WHERE attribute_id=" . $model->getId()); while ($row = $readresult->fetch()) { $customerForm[$row['form_code']] = 'checked'; } } /*$fieldset->addField('adminhtml_customer', 'checkbox', array( 'name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Adminhtml Customer'), 'value' => 'adminhtml_customer', 'checked' => isset($customerForm['adminhtml_customer'])?$customerForm['adminhtml_customer']:'', ));*/ $fieldset->addField('customer_account_edit', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Customer Account Edit'), 'value' => 'customer_account_edit', 'checked' => isset($customerForm['customer_account_edit']) ? $customerForm['customer_account_edit'] : '')); $fieldset->addField('adminhtml_customer_address', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Adminhtml Customer Address'), 'value' => 'adminhtml_customer_address', 'checked' => isset($customerForm['adminhtml_customer_address']) ? $customerForm['adminhtml_customer_address'] : '')); $fieldset->addField('checkout_register', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Checkout Register'), 'value' => 'checkout_register', 'checked' => isset($customerForm['checkout_register']) ? $customerForm['checkout_register'] : '')); $fieldset->addField('customer_account_create', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Customer Account Create'), 'value' => 'customer_account_create', 'checked' => isset($customerForm['customer_account_create']) ? $customerForm['customer_account_create'] : '')); $fieldset->addField('customer_register_address', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Customer Register Address'), 'value' => 'customer_register_address', 'checked' => isset($customerForm['customer_register_address']) ? $customerForm['customer_register_address'] : '')); $fieldset->addField('customer_address_edit', 'checkbox', array('name' => 'customer_form[]', 'label' => Mage::helper('catalog')->__('Customer Address Edit'), 'value' => 'customer_address_edit', 'checked' => isset($customerForm['customer_address_edit']) ? $customerForm['customer_address_edit'] : '')); $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('catalog')->__('Sort Order'), 'title' => Mage::helper('catalog')->__('Order in form'), 'class' => 'validate-digits', 'value' => $model->getAttributeSetInfo())); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } /* if (!$model->getIsUserDefined() && $model->getId()) { $form->getElement('is_unique')->setDisabled(1); } */ //var_dump($model->getData());exit; $form->addValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * Preparing form elements for editing Entity Type Attribute * * @return $this */ protected function _prepareForm() { parent::_prepareForm(); /** @var Goodahead_Etm_Model_Entity_Type $entityType */ $entityType = Mage::registry('etm_entity_type'); $attributeObject = $this->getAttributeObject(); /* @var $form Varien_Data_Form */ $form = $this->getForm(); /* @var $fieldset Varien_Data_Form_Element_Fieldset */ $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'image', 'label' => Mage::helper('catalog')->__('Media Image'))); if ($attributeObject->getFrontendInput() == 'gallery') { $additionalTypes[] = array('value' => 'gallery', 'label' => Mage::helper('catalog')->__('Gallery')); } $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('goodahead_etm_entity_attribute_types', array('response' => $response)); Mage::dispatchEvent(sprintf('goodahead_etm_%s_entity_attribute_types', $entityType->getEntityTypeCode()), array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes), 'attribute_code'); $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('core')->__('Sort Order'), 'title' => Mage::helper('core')->__('Sort Order'))); Mage::dispatchEvent('goodahead_etm_entity_attribute_edit_prepare_form', array('form' => $form, 'attribute' => $attributeObject)); return $this; }
/** * Retrieve additional element types * * @return array */ protected function _getAdditionalElementTypes() { $result = array('price' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price'), 'weight' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight'), 'gallery' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery'), 'image' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Image'), 'boolean' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Boolean'), 'textarea' => Mage::getConfig()->getBlockClassName('Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg')); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response)); foreach ($response->getTypes() as $typeName => $typeClass) { $result[$typeName] = $typeClass; } return $result; }
public static function getPredefinedTypes() { if (!is_array(self::$_predefinedTypes)) { $types = self::_getPredefinedTypes(); $response = new Varien_Object(array('types' => $types)); Mage::dispatchEvent('blcg_options_source_predefined_types', array('response' => $response)); if (is_array($types = $response->getTypes())) { self::$_predefinedTypes = $types; } else { self::$_predefinedTypes = array(); } } return self::$_predefinedTypes; }
protected function _initAdditionalElementTypes() { if (is_null($this->_additionalElementTypes)) { $result = array('tier_price' => Mage::getConfig()->getBlockClassName('udprod/vendor_product_form_tierPrice'), 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'), 'weight' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_weight'), 'gallery' => Mage::getConfig()->getBlockClassName('udprod/vendor_product_gallery'), 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'), 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean'), 'textarea' => Mage::getConfig()->getBlockClassName('udprod/vendor_product_wysiwyg'), 'product_categories' => Mage::getConfig()->getBlockClassName('udropship/categoriesField')); $events = array('adminhtml_catalog_product_edit_element_types', 'udprod_product_edit_element_types'); foreach ($events as $event) { $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent($event, array('response' => $response)); foreach ($response->getTypes() as $typeName => $typeClass) { $result[$typeName] = $typeClass; } } $this->_additionalElementTypes = $result; } return $this; }
protected function _prepareForm() { $model = Mage::registry('attributemanager_data'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('catalog')->__('Attribute Properties'))); if ($model->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('catalog')->__('No')), array('value' => 1, 'label' => Mage::helper('catalog')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes)); $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('catalog')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('catalog')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('catalog')->__('Date')), array('value' => 'boolean', 'label' => Mage::helper('catalog')->__('Yes/No')), array('value' => 'multiselect', 'label' => Mage::helper('catalog')->__('Multiple Select')), array('value' => 'select', 'label' => Mage::helper('catalog')->__('Dropdown'))); if ($this->getRequest()->getParam('type') === "catalog_category") { $inputTypes[] = array('value' => 'image', 'label' => Mage::helper('catalog')->__('Image')); } $response = new Varien_Object(); $response->setTypes(array()); //Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); /****** champs cachés dans le formulaire **********/ $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => Mage::getModel('eav/entity')->setType($this->getRequest()->getParam('type'))->getTypeId())); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); //// replaced code ////// // $fieldset->addField('attribute_set_id', 'hidden', array( // 'name' => 'attribute_set_id', // 'value' => Mage::getModel('eav/entity')->setType($this->getRequest ()->getParam ( 'type' ))->getTypeId() // )); ///// new code ////////// $setId = Mage::getModel('eav/entity_type')->loadByCode($this->getRequest()->getParam('type'))->getDefaultAttributeSetId(); $fieldset->addField('attribute_set_id', 'hidden', array('name' => 'attribute_set_id', 'value' => $setId)); ///// end /////////////// //// replaced code ////// // $fieldset->addField('attribute_group_id', 'hidden', array( // 'name' => 'attribute_group_id', // 'value' => Mage::getModel('eav/entity')->setType($this->getRequest ()->getParam ( 'type' ))->getTypeId() // )); ///// new code ////////// $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')->setAttributeSetFilter($setId)->load(); $defaultGroupId = 0; foreach ($groupCollection as $group) { if ($defaultGroupId == 0 or $group->getIsDefault()) { $defaultGroupId = $group->getId(); } } $fieldset->addField('attribute_group_id', 'hidden', array('name' => 'attribute_group_id', 'value' => $defaultGroupId)); ///// end /////////////// /*******************************************************/ $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('catalog')->__('Unique Value'), 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'), 'note' => Mage::helper('catalog')->__('Not shared with other products'), 'values' => $yesno)); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'values' => array(array('value' => '', 'label' => Mage::helper('catalog')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('catalog')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('catalog')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('catalog')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('catalog')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('catalog')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('catalog')->__('Frontend Properties'))); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('catalog')->__('Position'), 'title' => Mage::helper('catalog')->__('Position In Layered Navigation'), 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'), 'class' => 'validate-digits')); if ($model->getIsUserDefined() || !$model->getId()) { $fieldset->addField('is_visible_on_front', 'select', array('name' => 'is_visible_on_front', 'label' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'), 'title' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'), 'values' => $yesno)); } $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('catalog')->__('Order'), 'title' => Mage::helper('catalog')->__('Order in form'), 'note' => Mage::helper('catalog')->__('order of attribute in form edit/create. Leave blank for form bottom.'), 'class' => 'validate-digits', 'value' => $model->getAttributeSetInfo())); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } /* if (!$model->getIsUserDefined() && $model->getId()) { $form->getElement('is_unique')->setDisabled(1); } */ //var_dump($model->getData());exit; $form->addValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * Adding product form elements for editing attribute * * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main */ protected function _prepareForm() { parent::_prepareForm(); $attributeObject = $this->getAttributeObject(); /* @var $form Varien_Data_Form */ $form = $this->getForm(); /* @var $fieldset Varien_Data_Form_Element_Fieldset */ $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image'))); if ($attributeObject->getFrontendInput() == 'gallery') { $additionalTypes[] = array('value' => 'gallery', 'label' => Mage::helper('catalog')->__('Gallery')); } $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_product_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes), 'attribute_code'); $fieldset->addField('apply_to', 'apply', array('name' => 'apply_to[]', 'label' => Mage::helper('catalog')->__('Apply To'), 'values' => Mage_Catalog_Model_Product_Type::getOptions(), 'mode_labels' => array('all' => Mage::helper('catalog')->__('All Product Types'), 'custom' => Mage::helper('catalog')->__('Selected Product Types')), 'required' => true), 'frontend_class'); $fieldset->addField('is_configurable', 'select', array('name' => 'is_configurable', 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'), 'values' => $yesnoSource), 'apply_to'); // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('catalog')->__('Frontend Properties'))); $fieldset->addField('is_searchable', 'select', array('name' => 'is_searchable', 'label' => Mage::helper('catalog')->__('Use in Quick Search'), 'title' => Mage::helper('catalog')->__('Use in Quick Search'), 'values' => $yesnoSource)); $fieldset->addField('is_visible_in_advanced_search', 'select', array('name' => 'is_visible_in_advanced_search', 'label' => Mage::helper('catalog')->__('Use in Advanced Search'), 'title' => Mage::helper('catalog')->__('Use in Advanced Search'), 'values' => $yesnoSource)); $fieldset->addField('is_comparable', 'select', array('name' => 'is_comparable', 'label' => Mage::helper('catalog')->__('Comparable on Front-end'), 'title' => Mage::helper('catalog')->__('Comparable on Front-end'), 'values' => $yesnoSource)); $fieldset->addField('is_filterable', 'select', array('name' => 'is_filterable', 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"), 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'values' => array(array('value' => '0', 'label' => Mage::helper('catalog')->__('No')), array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')), array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)'))))); $fieldset->addField('is_filterable_in_search', 'select', array('name' => 'is_filterable_in_search', 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"), 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'values' => $yesnoSource)); $fieldset->addField('is_used_for_promo_rules', 'select', array('name' => 'is_used_for_promo_rules', 'label' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'), 'title' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'), 'values' => $yesnoSource)); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('catalog')->__('Position'), 'title' => Mage::helper('catalog')->__('Position in Layered Navigation'), 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'), 'class' => 'validate-digits')); $fieldset->addField('is_wysiwyg_enabled', 'select', array('name' => 'is_wysiwyg_enabled', 'label' => Mage::helper('catalog')->__('Enable WYSIWYG'), 'title' => Mage::helper('catalog')->__('Enable WYSIWYG'), 'values' => $yesnoSource)); $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array('name' => 'is_html_allowed_on_front', 'label' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'), 'title' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'), 'values' => $yesnoSource)); if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) { $attributeObject->setIsHtmlAllowedOnFront(1); } $fieldset->addField('is_visible_on_front', 'select', array('name' => 'is_visible_on_front', 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 'values' => $yesnoSource)); $fieldset->addField('used_in_product_listing', 'select', array('name' => 'used_in_product_listing', 'label' => Mage::helper('catalog')->__('Used in Product Listing'), 'title' => Mage::helper('catalog')->__('Used in Product Listing'), 'note' => Mage::helper('catalog')->__('Depends on design theme'), 'values' => $yesnoSource)); $fieldset->addField('used_for_sort_by', 'select', array('name' => 'used_for_sort_by', 'label' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'), 'title' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'), 'note' => Mage::helper('catalog')->__('Depends on design theme'), 'values' => $yesnoSource)); $form->getElement('apply_to')->setSize(5); if ($applyTo = $attributeObject->getApplyTo()) { $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo); $form->getElement('apply_to')->setValue($applyTo); } else { $form->getElement('apply_to')->addClass('no-display ignore-validate'); } // define field dependencies $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')->addFieldMap("frontend_input", 'frontend_input_type')->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')); Mage::dispatchEvent('adminhtml_catalog_product_attribute_edit_prepare_form', array('form' => $form, 'attribute' => $attributeObject)); return $this; }
protected function _prepareForm() { $model = Mage::registry('entity_attribute'); if (!Mage::app()->isSingleStoreMode()) { $model->setData('stores', explode(',', $model->getData('store_ids'))); } $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $disableAttributeFields = array(); $rewriteAttributeValue = array('status' => array('is_configurable' => 0)); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('catalog')->__('Attribute Properties'))); if ($model->getAttributeId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('catalog')->__('No')), array('value' => 1, 'label' => Mage::helper('catalog')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); if (!Mage::app()->isSingleStoreMode()) { $fieldset->addField('stores', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('cms')->__('Store View'), 'title' => Mage::helper('cms')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true))); } else { $fieldset->addField('stores', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId())); $model->setStoreId(Mage::app()->getStore(true)->getId()); } $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } /*$fieldset->addField('is_global', 'select', array( 'name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), // 'class' => 'no-display', 'values'=> $scopes ));*/ $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('catalog')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('catalog')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('catalog')->__('Date')), array('value' => 'datetime', 'label' => Mage::helper('catalog')->__('Date With Time')), array('value' => 'select', 'label' => Mage::helper('catalog')->__('Dropdown'))); $response = new Varien_Object(); $response->setTypes(array()); // do not need additional types Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } //Mage::register('attribute_type_hidden_fields', $_hiddenFields); //Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'values' => $yesno, 'value' => $model->getDefaultValue())); $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => $model->getDefaultValue(), 'format' => $dateFormatIso)); $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('is_visible_on_front', 'select', array('name' => 'is_visible_on_front', 'label' => Mage::helper('catalog')->__('Visible on Front-end'), 'title' => Mage::helper('catalog')->__('Visible on Front-end'), 'values' => $yesno)); /*$fieldset->addField('is_unique', 'select', array( 'name' => 'is_unique', 'label' => Mage::helper('catalog')->__('Unique Value'), 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'), 'note' => Mage::helper('catalog')->__('Not shared with other products'), 'values' => $yesno, ));*/ $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation'), 'title' => Mage::helper('catalog')->__('Input Validation'), 'values' => array(array('value' => '', 'label' => Mage::helper('catalog')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('catalog')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('catalog')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('catalog')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('catalog')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('catalog')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); /* $fieldset->addField('use_in_super_product', 'select', array( 'name' => 'use_in_super_product', 'label' => Mage::helper('catalog')->__('Apply To Configurable/Grouped Product'), 'values' => $yesno, )); */ /*$fieldset->addField('apply_to', 'apply', array( 'name' => 'apply_to[]', 'label' => Mage::helper('catalog')->__('Apply To'), 'values' => Mage_Catalog_Model_Product_Type::getOptions(), 'mode_labels' => array( 'all' => Mage::helper('catalog')->__('All Product Types'), 'custom' => Mage::helper('catalog')->__('Selected Product Types') ), 'required' => true ));*/ /*$fieldset->addField('is_configurable', 'select', array( 'name' => 'is_configurable', 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'), 'values' => $yesno, ));*/ // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('amorderattr')->__('Attribute Configuration'))); $fieldset->addField('checkout_step', 'select', array('name' => 'checkout_step', 'label' => Mage::helper('amorderattr')->__('Show On Checkout Step'), 'title' => Mage::helper('amorderattr')->__('Show On Checkout Step'), 'values' => array(array('value' => '2', 'label' => Mage::helper('amorderattr')->__('2. Billing Information')), array('value' => '3', 'label' => Mage::helper('amorderattr')->__('3. Shipping Information')), array('value' => '4', 'label' => Mage::helper('amorderattr')->__('4. Shipping Method')), array('value' => '5', 'label' => Mage::helper('amorderattr')->__('5. Payment Information'))))); $fieldset->addField('sorting_order', 'text', array('name' => 'sorting_order', 'label' => Mage::helper('catalog')->__('Display Sorting Order'), 'title' => Mage::helper('catalog')->__('Display Sorting Order'), 'note' => Mage::helper('catalog')->__('Numeric, used in front-end to sort attributes'))); $fieldset->addField('save_selected', 'select', array('name' => 'save_selected', 'label' => Mage::helper('amorderattr')->__('Save Entered Value For Future Checkout'), 'title' => Mage::helper('amorderattr')->__('Save Entered Value For Future Checkout'), 'note' => Mage::helper('catalog')->__('If set to "Yes", previously entered value will be used during checkout. Works for registered customers only.'), 'values' => $yesno)); $fieldset->addField('show_on_grid', 'select', array('name' => 'show_on_grid', 'label' => Mage::helper('amorderattr')->__('Show on Orders Grid'), 'title' => Mage::helper('amorderattr')->__('Show on Orders Grid'), 'values' => $yesno)); $fieldset->addField('include_pdf', 'select', array('name' => 'include_pdf', 'label' => Mage::helper('amorderattr')->__('Include Into PDF Documents'), 'title' => Mage::helper('amorderattr')->__('Include Into PDF Documents'), 'values' => $yesno)); $fieldset->addField('apply_default', 'select', array('name' => 'apply_default', 'label' => $this->__('Automatically Apply Default Value'), 'title' => $this->__('Automatically Apply Default Value'), 'note' => $this->__('If set to "Yes", the default value will be automatically applied for each order if attribute value is not entered or not visible at the frontend.'), 'values' => $yesno)); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); // if (isset($disableAttributeFields[$model->getAttributeCode()])) { // foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { // $form->getElement($field)->setDisabled(1); // } // } } // if (!$model->getIsUserDefined() && $model->getId()) { // $form->getElement('is_unique')->setDisabled(1); // } $form->addValues($model->getData()); if ($model->getId() && isset($rewriteAttributeValue[$model->getAttributeCode()])) { foreach ($rewriteAttributeValue[$model->getAttributeCode()] as $field => $value) { $form->getElement($field)->setValue($value); } } // $form->getElement('apply_to')->setSize(5); if ($applyTo = $model->getApplyTo()) { $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo); //$form->getElement('apply_to')->setValue($applyTo); } else { //$form->getElement('apply_to')->addClass('no-display ignore-validate'); } $this->setForm($form); return parent::_prepareForm(); }
protected function _prepareForm() { $model = Mage::registry('entity_attribute'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $disableAttributeFields = array('sku' => array('is_global', 'is_unique'), 'url_key' => array('is_unique')); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('catalog')->__('Attribute Properties'))); if ($model->getAttributeId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('catalog')->__('No')), array('value' => 1, 'label' => Mage::helper('catalog')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('catalog')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('catalog')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('catalog')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('catalog')->__('Scope'), 'title' => Mage::helper('catalog')->__('Scope'), 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'), 'values' => $scopes)); $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('catalog')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('catalog')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('catalog')->__('Date')), array('value' => 'boolean', 'label' => Mage::helper('catalog')->__('Yes/No')), array('value' => 'multiselect', 'label' => Mage::helper('catalog')->__('Multiple Select')), array('value' => 'select', 'label' => Mage::helper('catalog')->__('Dropdown')), array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'gallery', 'label' => Mage::helper('catalog')->__('Gallery')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image'))); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_product_attribute_types', array('response' => $response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'values' => $yesno, 'value' => $model->getDefaultValue())); $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => $model->getDefaultValue(), 'format' => $dateFormatIso)); $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('catalog')->__('Unique Value'), 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'), 'note' => Mage::helper('catalog')->__('Not shared with other products'), 'values' => $yesno)); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'), 'values' => array(array('value' => '', 'label' => Mage::helper('catalog')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('catalog')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('catalog')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('catalog')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('catalog')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('catalog')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); /* $fieldset->addField('use_in_super_product', 'select', array( 'name' => 'use_in_super_product', 'label' => Mage::helper('catalog')->__('Apply To Configurable/Grouped Product'), 'values' => $yesno, )); */ $fieldset->addField('apply_to', 'apply', array('name' => 'apply_to[]', 'label' => Mage::helper('catalog')->__('Apply To'), 'values' => Mage_Catalog_Model_Product_Type::getOptions(), 'mode_labels' => array('all' => Mage::helper('catalog')->__('All Product Types'), 'custom' => Mage::helper('catalog')->__('Selected Product Types')), 'required' => true)); $fieldset->addField('is_configurable', 'select', array('name' => 'is_configurable', 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'), 'values' => $yesno)); // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('catalog')->__('Frontend Properties'))); $fieldset->addField('is_searchable', 'select', array('name' => 'is_searchable', 'label' => Mage::helper('catalog')->__('Use in quick search'), 'title' => Mage::helper('catalog')->__('Use in quick search'), 'values' => $yesno)); $fieldset->addField('is_visible_in_advanced_search', 'select', array('name' => 'is_visible_in_advanced_search', 'label' => Mage::helper('catalog')->__('Use in advanced search'), 'title' => Mage::helper('catalog')->__('Use in advanced search'), 'values' => $yesno)); $fieldset->addField('is_comparable', 'select', array('name' => 'is_comparable', 'label' => Mage::helper('catalog')->__('Comparable on Front-end'), 'title' => Mage::helper('catalog')->__('Comparable on Front-end'), 'values' => $yesno)); $fieldset->addField('is_filterable', 'select', array('name' => 'is_filterable', 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"), 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'values' => array(array('value' => '0', 'label' => Mage::helper('catalog')->__('No')), array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')), array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)'))))); $fieldset->addField('is_filterable_in_search', 'select', array('name' => 'is_filterable_in_search', 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"), 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'values' => $yesno)); $fieldset->addField('is_used_for_price_rules', 'select', array('name' => 'is_used_for_price_rules', 'label' => Mage::helper('catalog')->__('Use for Price Rule Conditions'), 'title' => Mage::helper('catalog')->__('Use for Price Rule Conditions'), 'values' => $yesno)); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('catalog')->__('Position'), 'title' => Mage::helper('catalog')->__('Position In Layered Navigation'), 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'), 'class' => 'validate-digits')); $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array('name' => 'is_html_allowed_on_front', 'label' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'), 'title' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'), 'values' => $yesno)); if (!$model->getId()) { $htmlAllowed->setValue(1); } $fieldset->addField('is_visible_on_front', 'select', array('name' => 'is_visible_on_front', 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'), 'values' => $yesno)); $fieldset->addField('used_in_product_listing', 'select', array('name' => 'used_in_product_listing', 'label' => Mage::helper('catalog')->__('Used in product listing'), 'title' => Mage::helper('catalog')->__('Used in product listing'), 'note' => Mage::helper('catalog')->__('Depends on design theme'), 'values' => $yesno)); $fieldset->addField('used_for_sort_by', 'select', array('name' => 'used_for_sort_by', 'label' => Mage::helper('catalog')->__('Used for sorting in product listing'), 'title' => Mage::helper('catalog')->__('Used for sorting in product listing'), 'note' => Mage::helper('catalog')->__('Depends on design theme'), 'values' => $yesno)); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } if (!$model->getIsUserDefined() && $model->getId()) { $form->getElement('is_unique')->setDisabled(1); } $form->addValues($model->getData()); $form->getElement('apply_to')->setSize(5); if ($applyTo = $model->getApplyTo()) { $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo); $form->getElement('apply_to')->setValue($applyTo); } else { $form->getElement('apply_to')->addClass('no-display ignore-validate'); } $this->setForm($form); return parent::_prepareForm(); }
protected function _prepareForm() { $form = new Varien_Data_Form(); $this->setForm($form); $fieldset = $form->addFieldset('fieldsmanager_form', array('legend' => Mage::helper('fieldsmanager')->__('Fields Properties'))); $data = Mage::registry('fieldsmanager_data')->getData(); if (Mage::registry('fieldsmanager_data')->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('Must be unique and without spaces'), 'class' => 'validate-code', 'required' => true)); $modelType = Mage::getModel('fieldsmanager/type'); $response = new Varien_Object(); $response->setTypes(array()); $additionalTypes = array(); $additionalTypes = $modelType->toOptionArray(); //Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Input Type'), 'title' => Mage::helper('catalog')->__('Input Type'), 'value' => 'text', 'values' => $additionalTypes)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation'), 'title' => Mage::helper('catalog')->__('Input Validation'), 'values' => $modelType->toValidateArray())); $fieldset->addField('is_filterable', 'select', array('name' => 'is_filterable', 'label' => Mage::helper('catalog')->__('Field Placement'), 'title' => Mage::helper('catalog')->__('Field Placement'), 'values' => $modelType->toPositionArray())); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('catalog')->__('Position'), 'title' => Mage::helper('catalog')->__('Position'), 'note' => Mage::helper('catalog')->__('Will Use this value to sort the fields'), 'class' => 'validate-digits')); $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => Mage::getModel('eav/entity')->setType('fme_fieldsmanager')->getTypeId())); $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => Mage::registry('fieldsmanager_data')->getDefaultValue())); $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'values' => $yesno, 'value' => Mage::registry('fieldsmanager_data')->getDefaultValue())); $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $dateElement = $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => Mage::registry('fieldsmanager_data')->getDefaultValue(), 'class' => 'validate-date', 'format' => $dateFormatIso)); $dateElement->setValue(Mage::registry('fieldsmanager_data')->getDefaultValue(), $dateFormatIso); $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => Mage::registry('fieldsmanager_data')->getDefaultValue())); $fieldset->addField('default_value_message', 'textarea', array('name' => 'default_value_message', 'label' => Mage::helper('catalog')->__('Enter Your Message'), 'title' => Mage::helper('catalog')->__('Enter Your Message'), 'value' => Mage::registry('fieldsmanager_data')->getDefaultValue())); $fieldset->addField('is_used_for_price_rules', 'select', array('name' => 'is_used_for_price_rules', 'label' => Mage::helper('catalog')->__('Add default Empty option'), 'title' => Mage::helper('catalog')->__('Add default Empty option'), 'note' => Mage::helper('catalog')->__('If enabled then the drop down will add an empty option at the top'), 'value' => 0, 'values' => $yesno)); $fieldset->addField('is_searchable', 'select', array('name' => 'is_searchable', 'label' => Mage::helper('catalog')->__('Select for the Step'), 'title' => Mage::helper('catalog')->__('Select for the Step'), 'note' => Mage::helper('catalog')->__('Add the Field to Checkout process or Customer Registration Form'), 'values' => $modelType->toPlacementArray())); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('fme_customer_account', 'select', array('name' => 'fme_customer_account', 'label' => Mage::helper('catalog')->__("Add to Customer's Account"), 'title' => Mage::helper('catalog')->__("Add to Customer's Account"), 'values' => $modelType->toCustomerArray())); $fieldset->addField('fme_email', 'select', array('name' => 'fme_email', 'label' => Mage::helper('catalog')->__("Add to Emails"), 'title' => Mage::helper('catalog')->__("Add to Emails"), 'values' => $yesno)); $fieldset->addField('fme_pdf', 'select', array('name' => 'fme_pdf', 'label' => Mage::helper('catalog')->__('Add To Pdf'), 'title' => Mage::helper('catalog')->__('Add To Pdf'), 'values' => $modelType->toPdfArray())); $fieldset->addField('store_ids', 'multiselect', array('name' => 'store_ids[]', 'label' => $this->__('Store View'), 'title' => $this->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true))); $groups = Mage::getResourceModel('customer/group_collection')->load()->toOptionArray(); $fieldset->addField('custmoer_group', 'multiselect', array('name' => 'custmoer_group[]', 'label' => $this->__('Customer Group'), 'title' => $this->__('Customer Group'), 'required' => true, 'values' => $groups)); $fieldset->addField('is_global', 'hidden', array('name' => 'is_global', 'values' => 0), 'attribute_code'); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); $fieldset->addField('is_visible_in_advanced_search', 'hidden', array('name' => 'is_visible_in_advanced_search', 'value' => 0)); $fieldset->addField('is_comparable', 'hidden', array('name' => 'is_comparable', 'value' => 0)); $fieldset->addField('is_used_for_promo_rules', 'hidden', array('name' => 'is_used_for_promo_rules', 'value' => 0)); $fieldset->addField('is_wysiwyg_enabled', 'hidden', array('name' => 'is_wysiwyg_enabled', 'values' => 0)); $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'hidden', array('name' => 'is_html_allowed_on_front', 'values' => 0)); $fieldset->addField('is_visible_on_front', 'hidden', array('name' => 'is_visible_on_front', 'values' => 0)); $fieldset->addField('used_in_product_listing', 'hidden', array('name' => 'used_in_product_listing', 'value' => 0)); $fieldset->addField('used_for_sort_by', 'hidden', array('name' => 'used_for_sort_by', 'values' => 0)); if (Mage::registry('fieldsmanager_data')->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[Mage::registry('fieldsmanager_data')->getAttributeCode()])) { foreach ($disableAttributeFields[Mage::registry('fieldsmanager_data')->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } $form->addValues(Mage::registry('fieldsmanager_data')->getData()); $this->setForm($form); return parent::_prepareForm(); }
protected function _prepareForm() { $model = Mage::registry('entity_attribute'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('customerattribute')->__('Attribute Properties'))); if ($model->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('customerattribute')->__('No')), array('value' => 1, 'label' => Mage::helper('customerattribute')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('customerattribute')->__('Attribute Code'), 'title' => Mage::helper('customerattribute')->__('Attribute Code'), 'note' => Mage::helper('customerattribute')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('customerattribute')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('customerattribute')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('customerattribute')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $fieldset->addField('is_global', 'select', array('name' => 'is_global', 'label' => Mage::helper('customerattribute')->__('Scope'), 'title' => Mage::helper('customerattribute')->__('Scope'), 'note' => Mage::helper('customerattribute')->__('Declare attribute value saving scope'), 'values' => $scopes)); $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('customerattribute')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('customerattribute')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('customerattribute')->__('Date')), array('value' => 'boolean', 'label' => Mage::helper('customerattribute')->__('Yes/No')), array('value' => 'multiselect', 'label' => Mage::helper('customerattribute')->__('Multiple Select')), array('value' => 'select', 'label' => Mage::helper('customerattribute')->__('Dropdown'))); if ($this->getRequest()->getParam('type') === "catalog_category") { $inputTypes[] = array('value' => 'image', 'label' => Mage::helper('customerattribute')->__('Image')); } $response = new Varien_Object(); $response->setTypes(array()); //Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('customerattribute')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('customerattribute')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); /* * **** champs cach�s dans le formulaire ********* */ $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId())); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); $fieldset->addField('attribute_set_id', 'hidden', array('name' => 'attribute_set_id', 'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId())); $fieldset->addField('attribute_group_id', 'hidden', array('name' => 'attribute_group_id', 'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId())); /* * **************************************************** */ $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('customerattribute')->__('Unique Value'), 'title' => Mage::helper('customerattribute')->__('Unique Value'), 'values' => $yesno)); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('customerattribute')->__('Values Required'), 'title' => Mage::helper('customerattribute')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('customerattribute')->__('Input Validation for Store Owner'), 'title' => Mage::helper('customerattribute')->__('Input Validation for Store Owner'), 'values' => array(array('value' => '', 'label' => Mage::helper('customerattribute')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('customerattribute')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('customerattribute')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('customerattribute')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('customerattribute')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('customerattribute')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('customerattribute')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); // ----- // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('customerattribute')->__('Frontend Properties'))); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('customerattribute')->__('Position'), 'title' => Mage::helper('customerattribute')->__('Position In Layered Navigation'), 'note' => Mage::helper('customerattribute')->__('Position of attribute in layered navigation block'), 'class' => 'validate-digits', 'value' => $model->getPosition())); /* $fieldset->addField('sort_order', 'text', array( 'name' => 'sort_order', 'label' => Mage::helper('customerattribute')->__('Order'), 'title' => Mage::helper('customerattribute')->__('Order in form'), 'note' => Mage::helper('customerattribute')->__('order of attribute in form edit/create. Leave blank for form bottom.'), 'class' => 'validate-digits', 'value' => $model->getAttributeSetInfo() )); */ //Add to form $fieldset = $form->addFieldset('used_in_forms', array('legend' => Mage::helper('customerattribute')->__('Used in forms'))); $fieldset->addField('adminhtml_customer', 'checkbox', array('label' => Mage::helper('customerattribute')->__('Admin customer'), 'checked' => is_array($model->getUsedInForms()) && in_array('adminhtml_customer', $model->getUsedInForms()) ? true : false, 'name' => 'used_in_forms[]', 'class' => 'attribute-checkbox', 'value' => 'adminhtml_customer')); $fieldset->addField('customer_account_create', 'checkbox', array('label' => Mage::helper('customerattribute')->__('Customer Account Create'), 'checked' => is_array($model->getUsedInForms()) && in_array('customer_account_create', $model->getUsedInForms()) ? true : false, 'name' => 'used_in_forms[]', 'class' => 'attribute-checkbox', 'value' => 'customer_account_create')); $fieldset->addField('customer_account_edit', 'checkbox', array('label' => Mage::helper('customerattribute')->__('Customer Account Edit'), 'checked' => is_array($model->getUsedInForms()) && in_array('customer_account_edit', $model->getUsedInForms()) ? true : false, 'name' => 'used_in_forms[]', 'class' => 'attribute-checkbox', 'value' => 'customer_account_edit')); $fieldset->addField('checkout_register', 'checkbox', array('label' => Mage::helper('customerattribute')->__('Checkout Register'), 'checked' => is_array($model->getUsedInForms()) && in_array('checkout_register', $model->getUsedInForms()) ? true : false, 'name' => 'used_in_forms[]', 'class' => 'attribute-checkbox', 'value' => 'checkout_register')); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } $form->addValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
protected function _prepareForm() { $model = Mage::registry('entity_attribute'); if (!Mage::app()->isSingleStoreMode()) { $model->setData('stores', explode(',', $model->getData('store_ids'))); } $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $disableAttributeFields = array(); $rewriteAttributeValue = array('status' => array('is_configurable' => 0)); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('amcustomerattr')->__('Attribute Properties'))); if ($model->getAttributeId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 1, 'label' => Mage::helper('amcustomerattr')->__('Yes')), array('value' => 0, 'label' => Mage::helper('amcustomerattr')->__('No'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('amcustomerattr')->__('Attribute Code'), 'title' => Mage::helper('amcustomerattr')->__('Attribute Code - for internal use. Must be unique with no spaces'), 'note' => Mage::helper('amcustomerattr')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); if (!Mage::app()->isSingleStoreMode()) { $fieldset->addField('stores', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('amcustomerattr')->__('Store View'), 'title' => Mage::helper('amcustomerattr')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true))); } else { $fieldset->addField('stores', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId())); $model->setStoreId(Mage::app()->getStore(true)->getId()); } $scopes = array(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('amcustomerattr')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('amcustomerattr')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('amcustomerattr')->__('Global')); if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') { unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]); } $inputTypes = Mage::helper('amcustomerattr')->getAttributeTypes(); $response = new Varien_Object(); $response->setTypes(array()); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $inputTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } $ordinaryValidationRules = array(array('value' => '', 'label' => Mage::helper('amcustomerattr')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('amcustomerattr')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('amcustomerattr')->__('Integer Number')), array('value' => 'validate-tendigits', 'label' => Mage::helper('amcustomerattr')->__('10 Digits Integer Number')), array('value' => 'validate-aaa-0000', 'label' => Mage::helper('amcustomerattr')->__('AAA-0000')), array('value' => 'validate-email', 'label' => Mage::helper('amcustomerattr')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('amcustomerattr')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('amcustomerattr')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('amcustomerattr')->__('Letters(a-zA-Z) or Numbers(0-9)'))); $additionalValidationRules = array(); $additionalValidationRules = Mage::getModel('amcustomerattr/validation')->getAdditionalValidation(); $validationRules = array_merge($ordinaryValidationRules, $additionalValidationRules); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('amcustomerattr')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('amcustomerattr')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes)); $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('amcustomerattr')->__('Default value'), 'title' => Mage::helper('amcustomerattr')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('amcustomerattr')->__('Default value'), 'title' => Mage::helper('amcustomerattr')->__('Default value'), 'values' => $yesno, 'value' => $model->getDefaultValue())); $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('amcustomerattr')->__('Default value'), 'title' => Mage::helper('amcustomerattr')->__('Default value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => $model->getDefaultValue(), 'format' => $dateFormatIso)); $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('amcustomerattr')->__('Default value'), 'title' => Mage::helper('amcustomerattr')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('amcustomerattr')->__('Unique Value'), 'title' => Mage::helper('amcustomerattr')->__('Unique Value - not shared with other customers'), 'note' => Mage::helper('amcustomerattr')->__('Not shared with other customers'), 'values' => $yesno)); $requiredValues = $yesno; $requiredValues[] = array('value' => 2, 'label' => Mage::helper('amcustomerattr')->__('On the Frontend Only')); $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('amcustomerattr')->__('Values Required'), 'title' => Mage::helper('amcustomerattr')->__('Values Required'), 'values' => $requiredValues)); $fieldset->addField('is_read_only', 'select', array('name' => 'is_read_only', 'label' => Mage::helper('amcustomerattr')->__('Is Read Only'), 'title' => Mage::helper('amcustomerattr')->__('Is Read Only'), 'values' => $yesno)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('amcustomerattr')->__('Input Validation'), 'title' => Mage::helper('amcustomerattr')->__('Input Validation'), 'values' => $validationRules)); $fieldset->addField('file_size', 'text', array('name' => 'file_size', 'label' => Mage::helper('amcustomerattr')->__('Max File Size'), 'title' => Mage::helper('amcustomerattr')->__('Max File Size - in Mb'), 'note' => Mage::helper('amcustomerattr')->__('In Mb'))); $fieldset->addField('file_dimentions', 'text', array('name' => 'file_dimentions', 'label' => Mage::helper('amcustomerattr')->__('Image Dimentions'), 'title' => Mage::helper('amcustomerattr')->__('Image Dimentions - in pixels like: 30/40 (where 30 - width, 40 - height)'), 'note' => Mage::helper('amcustomerattr')->__('In pixels like: 30/40 (where 30 - width, 40 - height)'))); $fieldset->addField('file_types', 'text', array('name' => 'file_types', 'label' => Mage::helper('amcustomerattr')->__('File Types'), 'title' => Mage::helper('amcustomerattr')->__('File Types - list comma-separated file types with no spaces, like: png,txt,jpg'), 'note' => Mage::helper('amcustomerattr')->__('List comma-separated file types with no spaces, like: png,txt,jpg'))); // frontend properties fieldset $fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('amcustomerattr')->__('Attribute Configuration'))); $fieldset->addField('is_filterable_in_search', 'select', array('name' => 'is_filterable_in_search', 'label' => Mage::helper('amcustomerattr')->__('Show on the Customers Grid'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Customers Grid'), 'values' => $yesno)); $fieldset->addField('used_in_order_grid', 'select', array('name' => 'used_in_order_grid', 'label' => Mage::helper('amcustomerattr')->__('Show on the Orders Grid'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Orders Grid'), 'values' => $yesno)); $fieldset->addField('on_order_view', 'select', array('name' => 'on_order_view', 'label' => Mage::helper('amcustomerattr')->__('Show on the Order View page'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Order View page - in the Account Information block at the Backend'), 'note' => Mage::helper('amcustomerattr')->__('In the Account Information block at the Backend'), 'values' => $yesno)); $fieldset->addField('is_visible_on_front', 'select', array('name' => 'is_visible_on_front', 'label' => Mage::helper('amcustomerattr')->__('Show on the Account Information page'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Account Information page - on the Frontend'), 'note' => Mage::helper('amcustomerattr')->__('On the Frontend'), 'values' => $yesno)); $fieldset->addField('account_filled', 'select', array('name' => 'account_filled', 'label' => Mage::helper('amcustomerattr')->__('Do not Show if Filled'), 'title' => Mage::helper('amcustomerattr')->__('Do not Show if Filled - on the Account Information page on the Frontend'), 'note' => Mage::helper('amcustomerattr')->__('On the Account Information page on the Frontend'), 'values' => $yesno)); $fieldset->addField('used_in_product_listing', 'select', array('name' => 'used_in_product_listing', 'label' => Mage::helper('amcustomerattr')->__('Show on the Billing page'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Billing page - during Checkout'), 'note' => Mage::helper('amcustomerattr')->__('During Checkout'), 'values' => $yesno)); $fieldset->addField('billing_filled', 'select', array('name' => 'billing_filled', 'label' => Mage::helper('amcustomerattr')->__('Do not Show if Filled'), 'title' => Mage::helper('amcustomerattr')->__('Do not Show if Filled - on the Billing page during Checkout'), 'note' => Mage::helper('amcustomerattr')->__('On the Billing page during Checkout'), 'values' => $yesno)); $fieldset->addField('on_registration', 'select', array('name' => 'on_registration', 'label' => Mage::helper('amcustomerattr')->__('Show on the Registration page'), 'title' => Mage::helper('amcustomerattr')->__('Show on the Registration page'), 'values' => $yesno)); $fieldset->addField('sorting_order', 'text', array('name' => 'sorting_order', 'label' => Mage::helper('amcustomerattr')->__('Sorting Order'), 'title' => Mage::helper('amcustomerattr')->__('Sorting Order - the order to display field on Frontend'), 'note' => Mage::helper('amcustomerattr')->__('The order to display field on frontend'))); $values = $model->getData(); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if ($values['required_on_front']) { $values['is_required'] = 2; } } $form->addValues($values); if ($model->getId() && isset($rewriteAttributeValue[$model->getAttributeCode()])) { foreach ($rewriteAttributeValue[$model->getAttributeCode()] as $field => $value) { $form->getElement($field)->setValue($value); } } if ($applyTo = $model->getApplyTo()) { $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo); } $this->setForm($form); return parent::_prepareForm(); }
protected function _prepareForm() { $iTypeId = Mage::getModel('eav/entity')->setType('aitoc_checkout')->getTypeId(); $model = Mage::registry('aitcheckoutfields_data'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('catalog')->__('Attribute Properties'))); if ($model->getId()) { $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id')); } $this->_addElementTypes($fieldset); $yesno = array(array('value' => 0, 'label' => Mage::helper('catalog')->__('No')), array('value' => 1, 'label' => Mage::helper('catalog')->__('Yes'))); $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('catalog')->__('Attribute Code'), 'title' => Mage::helper('catalog')->__('Attribute Code'), 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'), 'class' => 'validate-code', 'required' => true)); $inputTypes = array(array('value' => 'text', 'label' => Mage::helper('catalog')->__('Text Field')), array('value' => 'textarea', 'label' => Mage::helper('catalog')->__('Text Area')), array('value' => 'date', 'label' => Mage::helper('catalog')->__('Date')), array('value' => 'boolean', 'label' => Mage::helper('catalog')->__('Yes/No')), array('value' => 'multiselect', 'label' => Mage::helper('catalog')->__('Multiple Select')), array('value' => 'select', 'label' => Mage::helper('catalog')->__('Dropdown')), array('value' => 'checkbox', 'label' => Mage::helper('catalog')->__('Checkbox')), array('value' => 'radio', 'label' => Mage::helper('catalog')->__('Radiobutton')), array('value' => 'static', 'label' => Mage::helper('catalog')->__('Static Text'))); $response = new Varien_Object(); $response->setTypes(array()); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $iTypeId) { $inputTypes[] = $iTypeId; if (isset($iTypeId['hide_fields'])) { $_hiddenFields[$iTypeId['value']] = $iTypeId['hide_fields']; } if (isset($iTypeId['disabled_types'])) { $_disabledTypes[$iTypeId['value']] = $iTypeId['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('catalog')->__('Input Type'), 'title' => Mage::helper('catalog')->__('Input Type'), 'value' => 'text', 'values' => $inputTypes)); $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('catalog')->__('Input Validation'), 'title' => Mage::helper('catalog')->__('Input Validation'), 'values' => array(array('value' => '', 'label' => Mage::helper('catalog')->__('None')), array('value' => 'validate-number', 'label' => Mage::helper('catalog')->__('Decimal Number')), array('value' => 'validate-digits', 'label' => Mage::helper('catalog')->__('Integer Number')), array('value' => 'validate-email', 'label' => Mage::helper('catalog')->__('Email')), array('value' => 'validate-url', 'label' => Mage::helper('catalog')->__('Url')), array('value' => 'validate-alpha', 'label' => Mage::helper('catalog')->__('Letters')), array('value' => 'validate-alphanum', 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)'))))); $fieldset->addField('is_filterable', 'select', array('name' => 'is_filterable', 'label' => Mage::helper('catalog')->__('Attribute Placeholder'), 'title' => Mage::helper('catalog')->__('Attribute Placeholder'), 'note' => Mage::helper('catalog')->__('If you choose "On Top", the attribute will be displayed in the top placeholder of the checkout step and vice versa if you choose "At the Bottom"'), 'required' => true, 'values' => array(array('value' => 1, 'label' => Mage::helper('catalog')->__('On Top')), array('value' => 2, 'label' => Mage::helper('catalog')->__('At the bottom'))))); $fieldset->addField('position', 'text', array('name' => 'position', 'label' => Mage::helper('catalog')->__('Position in Placeholder'), 'title' => Mage::helper('catalog')->__('Position in Placeholder'), 'note' => Mage::helper('catalog')->__('Can be used to manage attributes\' positions when there are more than one attribute in one placeholder'), 'class' => 'validate-digits')); /****** champs cach�s dans le formulaire **********/ $fieldset->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => $iTypeId)); $fieldset->addField('is_user_defined', 'hidden', array('name' => 'is_user_defined', 'value' => 1)); /************ START AITOC CHECKOUT ATTRIBUTES ************/ $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'values' => $yesno, 'value' => $model->getDefaultValue())); $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $dateElement = $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => $model->getDefaultValue(), 'format' => $dateFormatIso)); $dateElement->setValue($model->getDefaultValue(), $dateFormatIso); $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('catalog')->__('Default value'), 'title' => Mage::helper('catalog')->__('Default value'), 'value' => $model->getDefaultValue())); $fieldset->addField('default_value_static', 'textarea', array('name' => 'default_value_static', 'label' => Mage::helper('catalog')->__('Text'), 'title' => Mage::helper('catalog')->__('Text'), 'value' => $model->getDefaultValue())); // for one page checkout $fieldset->addField('is_searchable', 'select', array('name' => 'is_searchable', 'label' => Mage::helper('catalog')->__('Step (for one page)'), 'title' => Mage::helper('catalog')->__('Step (for one page)'), 'note' => Mage::helper('catalog')->__('Add the attribute to a step of the one page checkout'), 'values' => Mage::helper('aitcheckoutfields')->getStepData('onepage'))); // for multi-address checkout $fieldset->addField('is_comparable', 'select', array('name' => 'is_comparable', 'label' => Mage::helper('catalog')->__('Step (for multi-address)'), 'title' => Mage::helper('catalog')->__('Step (for multi-address)'), 'note' => Mage::helper('catalog')->__('Add the attribute to a step of the multi-address checkout'), 'values' => Mage::helper('aitcheckoutfields')->getStepData('multipage'))); // new field $fieldset->addField('used_in_product_listing', 'select', array('name' => 'used_in_product_listing', 'label' => Mage::helper('catalog')->__('Add default "Please Select" option'), 'title' => Mage::helper('catalog')->__('Add default "Please Select" option'), 'note' => Mage::helper('catalog')->__('If set to "Yes" and Values Are Required customers will not be able to proceed to the next checkout step until they select a different option'), 'value' => 0, 'values' => $yesno)); /************ FINISH AITOC CHECKOUT ATTRIBUTES ************/ $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('catalog')->__('Values Required'), 'title' => Mage::helper('catalog')->__('Values Required'), 'values' => $yesno)); $fieldset->addField('is_used_for_price_rules', 'select', array('name' => 'is_used_for_price_rules', 'label' => Mage::helper('catalog')->__('Display on Order Page in Admin Area'), 'title' => Mage::helper('catalog')->__('Display on Order Page in Admin Area'), 'value' => 1, 'values' => $yesno)); $fieldset->addField('is_display_in_invoice', 'select', array('name' => 'is_display_in_invoice', 'label' => Mage::helper('catalog')->__('Display on Invoice Page in Admin Area'), 'title' => Mage::helper('catalog')->__('Display on Invoice Page in Admin Area'), 'value' => 1, 'values' => $yesno)); $fieldset->addField('is_filterable_in_search', 'select', array('name' => 'is_filterable_in_search', 'label' => Mage::helper('catalog')->__('Display on Order Page in Member Area'), 'title' => Mage::helper('catalog')->__('Display on Order Page in Member Area'), 'value' => 1, 'values' => $yesno)); $fieldset->addField('ait_filterable', 'select', array('name' => 'ait_filterable', 'label' => Mage::helper('catalog')->__('Use on Sales Grid'), 'title' => Mage::helper('catalog')->__('Use on Sales Grid'), 'value' => 0, 'values' => $yesno)); $fieldset->addField('ait_registration_page', 'select', array('name' => 'ait_registration_page', 'label' => Mage::helper('catalog')->__('Use on Registration Page'), 'title' => Mage::helper('catalog')->__('Use on Registration Page'), 'value' => 0, 'values' => $yesno)); $fieldset->addField('ait_registration_place', 'select', array('name' => 'ait_registration_place', 'label' => Mage::helper('catalog')->__('Attribute Placeholder (Registration)'), 'title' => Mage::helper('catalog')->__('Attribute Placeholder (Registration)'), 'note' => Mage::helper('catalog')->__('If you choose "On Top", the attribute will be displayed in the top placeholder of the registration page and vice versa if you choose "At the Bottom"'), 'values' => array(array('value' => 1, 'label' => Mage::helper('catalog')->__('On Top')), array('value' => 2, 'label' => Mage::helper('catalog')->__('At the bottom'))))); $fieldset->addField('ait_registration_position', 'text', array('name' => 'ait_registration_position', 'label' => Mage::helper('catalog')->__('Position in Placeholder (Registration)'), 'title' => Mage::helper('catalog')->__('Position in Placeholder (Registration)'), 'note' => Mage::helper('catalog')->__('Can be used to manage attributes\' positions on registration page when there are more than one attribute in one placeholder'), 'class' => 'validate-digits')); $fieldset->addField('ait_in_excel', 'select', array('name' => 'ait_in_excel', 'label' => Mage::helper('catalog')->__('Use for excel export'), 'title' => Mage::helper('catalog')->__('Use for excel export'), 'value' => 1, 'values' => $yesno)); $fieldset->addField('ait_product_category_dependant', 'select', array('name' => 'ait_product_category_dependant', 'label' => Mage::helper('catalog')->__('Depends on product/category of product in cart'), 'title' => Mage::helper('catalog')->__('Depends on product/category of product in cart'), 'value' => 0, 'values' => $yesno, 'note' => Mage::helper('catalog')->__('Only displayed if certain product or product of certain category is added to cart'))); if ($model->getId()) { $form->getElement('attribute_code')->setDisabled(1); $form->getElement('frontend_input')->setDisabled(1); if (isset($disableAttributeFields[$model->getAttributeCode()])) { foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) { $form->getElement($field)->setDisabled(1); } } } $form->addValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }