本文整理汇总了PHP中Mage_Adminhtml_Block_Catalog_Form::_prepareForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Catalog_Form::_prepareForm方法的具体用法?PHP Mage_Adminhtml_Block_Catalog_Form::_prepareForm怎么用?PHP Mage_Adminhtml_Block_Catalog_Form::_prepareForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Adminhtml_Block_Catalog_Form
的用法示例。
在下文中一共展示了Mage_Adminhtml_Block_Catalog_Form::_prepareForm方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
/**
* Create the form
*
* @return Smile_VirtualCategories_Block_Adminhtml_Catalog_Category_Tab_Product
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('virtual_');
$this->_prepareCategoryTypeSelector($form)->_prepareVirtualRuleFieldset($form)->_prepareLegacyProductSelector($form);
$form->setFieldNameSuffix('general');
$form->addValues($this->getCategory()->getData());
$this->setForm($form);
$this->setTemplate('smile/virtualcategories/category/product_select_form.phtml');
return parent::_prepareForm();
}
示例2: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('group_mep');
$form->setDataObject($this->getCategory());
$fieldset = $form->addFieldset('fieldset_group_mep', array('legend' => Mage::helper('mep')->__('MEP Mappings'), 'class' => 'fieldset-wide'));
/* @var $collection Flagbit_MEP_Model_Mysql4_Attribute_Mapping_Collection */
$collection = Mage::getModel('mep/attribute_mapping')->getCollection()->addFieldToFilter('source_attribute_code', 'category');
foreach ($collection as $mapping) {
$fieldset->addField('mapping_' . $mapping->getId(), 'text', array('label' => $mapping->getName(), 'name' => 'mapping_' . $mapping->getId(), 'note' => $this->getHintByType($mapping->getCategoryType()) . ', ' . Mage::helper('mep')->__('Attribute Code: %s', $mapping->getAttributeCode())));
}
$form->addValues($this->_getValuesByMappingCollection($collection, $this->getCategory()->getStoreId()));
$form->setFieldNameSuffix('mep');
$this->setForm($form);
return parent::_prepareForm();
}
示例3: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes
*/
protected function _prepareForm()
{
$group = $this->getGroup();
$attributes = $this->getAttributes();
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('group_' . $group->getId());
$form->setDataObject($this->getCategory());
$fieldset = $form->addFieldset('fieldset_group_' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
if ($this->getAddHiddenFields()) {
if (!$this->getCategory()->getId()) {
// path
if ($this->getRequest()->getParam('parent')) {
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $this->getRequest()->getParam('parent')));
} else {
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => 1));
}
} else {
$fieldset->addField('id', 'hidden', array('name' => 'id', 'value' => $this->getCategory()->getId()));
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $this->getCategory()->getPath()));
}
}
$this->_setFieldset($attributes, $fieldset);
foreach ($attributes as $attribute) {
$rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
if ($attribute->getAttributeCode() == 'url_key') {
if (!$this->getCategory()->getId() && $this->getRequest()->getParam('parent', $rootId) == $rootId || $this->getCategory()->getParentId() == $rootId) {
$fieldset->removeField('url_key');
} else {
$form->getElement('url_key')->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey'));
}
}
}
if ($this->getCategory()->getLevel() == 1) {
$fieldset->removeField('custom_use_parent_settings');
} else {
if ($this->getCategory()->getCustomUseParentSettings()) {
foreach ($this->getCategory()->getDesignAttributes() as $attribute) {
if ($element = $form->getElement($attribute->getAttributeCode())) {
$element->setDisabled(true);
}
}
}
if ($element = $form->getElement('custom_use_parent_settings')) {
$element->setData('onchange', 'onCustomUseParentChanged(this)');
}
}
if ($this->getCategory()->hasLockedAttributes()) {
foreach ($this->getCategory()->getLockedAttributes() as $attribute) {
if ($element = $form->getElement($attribute)) {
$element->setReadonly(true, true);
}
}
}
if (!$this->getCategory()->getId()) {
$this->getCategory()->setIncludeInMenu(1);
}
$form->addValues($this->getCategory()->getData());
Mage::dispatchEvent('adminhtml_catalog_category_edit_prepare_form', array('form' => $form));
$form->setFieldNameSuffix('general');
$this->setForm($form);
return parent::_prepareForm();
}
示例4: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes
*/
protected function _prepareForm()
{
$group = $this->getGroup();
$attributes = $this->getAttributes();
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('group_' . $group->getId());
$form->setDataObject($this->getCategory());
$fieldset = $form->addFieldset('fieldset_group_' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
if ($this->getAddHiddenFields()) {
if (!$this->getCategory()->getId()) {
// path
if ($this->getRequest()->getParam('parent')) {
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $this->getRequest()->getParam('parent')));
} else {
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => 1));
}
} else {
$fieldset->addField('id', 'hidden', array('name' => 'id', 'value' => $this->getCategory()->getId()));
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $this->getCategory()->getPath()));
}
}
$this->_setFieldset($attributes, $fieldset);
foreach ($attributes as $attribute) {
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
if ($attribute->getAttributeCode() == 'url_key') {
if ($this->getCategory()->getLevel() == 1) {
$fieldset->removeField('url_key');
$fieldset->addField('url_key', 'hidden', array('name' => 'url_key', 'value' => $this->getCategory()->getUrlKey()));
}
}
}
if ($this->getCategory()->hasLockedAttributes()) {
foreach ($this->getCategory()->getLockedAttributes() as $attribute) {
if ($element = $form->getElement($attribute)) {
$element->setReadonly(true, true);
}
}
}
$form->addValues($this->getCategory()->getData());
$form->setFieldNameSuffix('general');
$this->setForm($form);
return parent::_prepareForm();
}
示例5: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('googleoptimizer_fields', array('legend' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Google Optimizer Scripts')));
if ($this->getProduct()->getStoreId() == '0') {
Mage::helper('Mage_GoogleOptimizer_Helper_Data')->setStoreId(Mage::app()->getDefaultStoreView());
} else {
Mage::helper('Mage_GoogleOptimizer_Helper_Data')->setStoreId($this->getProduct()->getStoreId());
}
$disabledScriptsFields = false;
$values = array();
if ($this->getGoogleOptimizer() && $this->getGoogleOptimizer()->getData()) {
$disabledScriptsFields = true;
$values = $this->getGoogleOptimizer()->getData();
$checkedUseDefault = true;
if ($this->getGoogleOptimizer()->getStoreId() == $this->getProduct()->getStoreId()) {
$checkedUseDefault = false;
$disabledScriptsFields = false;
$fieldset->addField('code_id', 'hidden', array('name' => 'code_id'));
}
// show 'use default' checkbox if store different for default and product has scripts for default store
if ($this->getProduct()->getStoreId() != '0') {
$fieldset->addField('store_flag', 'checkbox', array('name' => 'store_flag', 'value' => '1', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Use Default Values'), 'class' => 'checkbox', 'required' => false, 'onchange' => 'googleOptimizerScopeAction()'))->setIsChecked($checkedUseDefault);
}
}
$fieldset->addField('conversion_page', 'select', array('name' => 'conversion_page', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Conversion Page'), 'values' => Mage::getModel('Mage_GoogleOptimizer_Model_Adminhtml_System_Config_Source_Googleoptimizer_Conversionpages')->toOptionArray(), 'class' => 'select googleoptimizer validate-googleoptimizer', 'required' => false, 'onchange' => 'googleOptimizerConversionPageAction(this)'));
if ($this->getProduct()->getStoreId() == '0' && !Mage::app()->hasSingleStore()) {
$fieldset->addField('conversion_page_url', 'note', array('name' => 'conversion_page_url', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Conversion Page URL'), 'text' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Please select store view to see the URL.')));
} else {
$fieldset->addField('conversion_page_url', 'text', array('name' => 'conversion_page_url', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Conversion Page URL'), 'class' => 'input-text', 'readonly' => 'readonly', 'required' => false, 'note' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Please copy and paste this value to experiment edit form.')));
}
$fieldset->addField('export_controls', 'text', array('name' => 'export_controls'));
$fieldset->addField('control_script', 'textarea', array('name' => 'control_script', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Control Script'), 'class' => 'textarea googleoptimizer validate-googleoptimizer', 'required' => false));
$fieldset->addField('tracking_script', 'textarea', array('name' => 'tracking_script', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Tracking Script'), 'class' => 'textarea googleoptimizer validate-googleoptimizer', 'required' => false));
$fieldset->addField('conversion_script', 'textarea', array('name' => 'conversion_script', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Conversion Script'), 'class' => 'textarea googleoptimizer validate-googleoptimizer', 'required' => false));
$attributes = Mage::helper('Mage_GoogleOptimizer_Helper_Data')->getProductAttributes($this->getProduct());
$fieldset->addField('attributes', 'multiselect', array('name' => 'attributes', 'label' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('Attributes'), 'class' => 'googleoptimizer validate-googleoptimizer validate-googleoptimizer-attributes', 'values' => $attributes, 'required' => false, 'onchange' => 'googleOptimizerAttributesCheckAction(this)', 'note' => Mage::helper('Mage_GoogleOptimizer_Helper_Data')->__('The limit is 8 attributes only.')));
if (Mage::helper('Mage_GoogleOptimizer_Helper_Data')->getConversionPagesUrl() && $this->getGoogleOptimizer() && $this->getGoogleOptimizer()->getConversionPage()) {
$form->getElement('conversion_page_url')->setValue(Mage::helper('Mage_GoogleOptimizer_Helper_Data')->getConversionPagesUrl()->getData($this->getGoogleOptimizer()->getConversionPage()));
}
if ($disabledScriptsFields) {
foreach ($fieldset->getElements() as $element) {
if ($element->getType() == 'textarea' || $element->getType() == 'select') {
$element->setDisabled($disabledScriptsFields);
}
}
$form->getElement('export_controls')->setDisabled($disabledScriptsFields);
}
$fakeEntityAttribute = Mage::getModel('Mage_Catalog_Model_Resource_Eav_Attribute');
foreach ($fieldset->getElements() as $element) {
if ($element->getId() != 'store_flag') {
$element->setEntityAttribute($fakeEntityAttribute);
}
}
$form->getElement('export_controls')->setRenderer($this->getLayout()->createBlock('Mage_GoogleOptimizer_Block_Adminhtml_Catalog_Form_Renderer_Import'));
$form->addValues($values);
$form->setFieldNameSuffix('googleoptimizer');
$this->setForm($form);
return parent::_prepareForm();
}
示例6: _prepareForm
protected function _prepareForm()
{
$product = $this->getProduct();
if (!($setId = $product->getAttributeSetId())) {
$setId = $this->getRequest()->getParam('set', null);
}
if ($setId) {
$attributeGroupId = Mage::getConfig()->getNode(Faett_Package_Helper_Data::FAETT_PACKAGE_LINK_GROUP_ID, 'default', 0);
$group = Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId);
$attributes = $product->getAttributes($group->getId(), true);
// do not add groups without attributes
foreach ($attributes as $key => $attribute) {
if (!$attribute->getIsVisible()) {
unset($attributes[$key]);
}
}
// sort the attributes after their position
usort($attributes, array($this, '_cmp'));
if (count($attributes) == 0) {
return;
}
$form = new Varien_Data_Form();
// initialize product object as form property for using it in elements generation
$form->setDataObject(Mage::registry('product'));
$fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName())));
$this->_setFieldset($attributes, $fieldset, array('gallery'));
if (!$form->getElement('media_gallery') && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
$headerBar = $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_attributes_create');
$headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
$fieldset->setHeaderBar($headerBar->toHtml());
}
$values = Mage::registry('product')->getData();
if (!Mage::registry('product')->getId()) {
foreach ($attributes as $attribute) {
if (!isset($values[$attribute->getAttributeCode()])) {
$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}
}
}
if (Mage::registry('product')->hasLockedAttributes()) {
foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
if ($element = $form->getElement($attribute)) {
$element->setReadonly(true, true);
}
}
}
$form->addValues($values);
$form->setFieldNameSuffix('product');
$this->setForm($form);
}
return parent::_prepareForm();
}