本文整理汇总了PHP中Varien_Data_Form_Element_Fieldset类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Fieldset类的具体用法?PHP Varien_Data_Form_Element_Fieldset怎么用?PHP Varien_Data_Form_Element_Fieldset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Data_Form_Element_Fieldset类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepareAttributes
/**
* Render required attributes
* @param Varien_Data_Form_Element_Fieldset $fldAttr
* @param Amasty_Banners_Model_Rule $model
*/
protected function prepareAttributes($fldAttr, $model)
{
$hlp = Mage::helper('ambanners');
/*
* Add Empty Fields user for new conditions
*/
$fieldSet = $this->getForm()->addFieldset('attributestmp', array('legend' => $hlp->__('Attribute Tmp')));
$fieldSet->addField('attr_code[][]', 'select', array('label' => $hlp->__('Has attribute'), 'name' => 'attr_code[]', 'values' => $this->getAttributes(), 'onchange' => 'showOptions(this)'));
$fieldSet->addField('attr_value[][]', 'text', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[]'));
$array = $model->getAttributesAsArray();
foreach ($array as $attributeCode => $attributeValue) {
if (empty($attributeCode)) {
continue;
}
if (is_array($attributeValue)) {
foreach ($attributeValue as $i => $value) {
/*
* Add Attribute Names
*/
$elementCode = $attributeCode . '-' . $value . '-' . $i;
$fldAttr->addField('attr_code[' . $elementCode . ']', 'select', array('label' => $hlp->__('Has attribute'), 'name' => 'attr_code[' . $elementCode . ']', 'values' => $this->getAttributes(), 'onchange' => 'showOptions(this)', 'value' => $attributeCode, 'note' => $hlp->__('If attribute is related to configurable products, please make sure that attribute is used in layered navigation'), 'after_element_html' => '<a href="#" onclick="landingRemove(this);return false;" title="' . $hlp->__('Remove') . '">' . $hlp->__('X') . '</a>'));
/*
* Add Attribute Options
*/
$attribute = Mage::getModel('catalog/product')->getResource()->getAttribute($attributeCode);
if ('select' === $attribute->getFrontendInput() || 'multiselect' === $attribute->getFrontendInput()) {
$options = $attribute->getFrontend()->getSelectOptions();
$fldAttr->addField('attr_value[' . $elementCode . ']', 'select', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[' . $elementCode . ']', 'values' => $options, 'value' => $value));
} else {
$fldAttr->addField('attr_value[' . $elementCode . ']', 'text', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[' . $elementCode . ']', 'value' => $value));
}
}
}
}
}
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:40,代码来源:Banners.php
示例2: addField
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param string $id
* @param string $type
* @param array $options
* @return Varien_Data_Form_Element_Abstract
*/
public function addField($fieldset, $id, $type, $options)
{
/** @noinspection PhpParamsInspection */
$field = $fieldset->addField($id, $type, $options);
if (isset($options['values'])) {
$field->setValues($options['values']);
}
$field->setRenderer($this->getFieldRenderer());
return $field;
}
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:17,代码来源:Form.php
示例3: createFieldConditions
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @return Varien_Data_Form_Element_Abstract
*/
private function createFieldConditions(Varien_Data_Form_Element_Fieldset $fieldset)
{
/** @var Varien_Data_Form_Element_Abstract $result */
$result = $fieldset->addField('conditions', 'text', array('name' => 'conditions', 'label' => Mage::helper('catalogrule')->__('Conditions'), 'title' => Mage::helper('catalogrule')->__('Conditions'), 'required' => true));
/** @var Mage_Rule_Block_Conditions $blockRuleConditions */
$blockRuleConditions = Mage::getBlockSingleton('rule/conditions');
$result->setData('rule', $this->getRule());
$result->setRenderer($blockRuleConditions);
df_assert($result instanceof Varien_Data_Form_Element_Abstract);
return $result;
}
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:15,代码来源:Conditions.php
示例4: _addFieldsToFieldset
/**
* This method makes life a little easier for us by pre-populating
* fields with $_POST data where applicable and wraps our post data in
* 'newsData' so we can easily separate all relevant information in
* the controller. You can of course omit this method entirely and call
* the $fieldset->addField() method directly.
*/
protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
{
$requestData = new Varien_Object($this->getRequest()->getPost('newsData'));
foreach ($fields as $name => $_data) {
if ($requestValue = $requestData->getData($name)) {
$_data['value'] = $requestValue;
}
// wrap all fields with newsData group
$_data['name'] = "newsData[{$name}]";
// generally label and title always the same
$_data['title'] = $_data['label'];
// finally call vanilla functionality to add field
$fieldset->addField($name, $_data['input'], $_data);
}
return $this;
}
开发者ID:215jc,项目名称:magento_newsview,代码行数:23,代码来源:Form.php
示例5: addField
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param string $id
* @param string $type
* @param array $options
* @return Varien_Data_Form_Element_Abstract
*/
public function addField($fieldset, $id, $type, $options)
{
if (isset($options['renderer'])) {
$renderer = $this->getLayout()->getBlockSingleton($options['renderer']);
unset($options['renderer']);
} else {
$renderer = $this->getFieldRenderer();
}
/** @noinspection PhpParamsInspection */
$field = $fieldset->addField($id, $type, $options);
if (isset($options['values'])) {
$field->setValues($options['values']);
}
$field->setRenderer($renderer);
return $field;
}
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:23,代码来源:Form.php
示例6: _addFieldsToFieldset
protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
{
$requestData = new Varien_Object($this->getRequest()->getPost('accordionData'));
foreach ($fields as $name => $_data) {
if ($requestValue = $requestData->getData($name)) {
$_data['value'] = $requestValue;
}
# code...
$_data['name'] = "accordionData[{$name}]";
$_data['title'] = $_data['label'];
if (!array_key_exists('value', $_data)) {
$_data['value'] = $this->_getAccordion()->getData($name);
}
$fieldset->addField($name, $_data['input'], $_data);
}
return $this;
}
开发者ID:bhargavmehta,项目名称:accordion,代码行数:17,代码来源:Form.php
示例7: _addModule
/**
* @param Aitoc_Aitsys_Model_Module $module
* @param Varien_Data_Form_Element_Fieldset $fieldset
*/
protected function _addModule(Aitoc_Aitsys_Model_Module $module, Varien_Data_Form_Element_Fieldset $fieldset)
{
if ($module->isIgnore()) {
return false;
}
$aModule = $module;
$label = $module->getInfo()->getLabel() . ($module->getInfo()->getVersion() ? ' v' . $module->getInfo()->getVersion() : '');
$message = '';
$messageType = 'notice-msg';
$isDemo = false;
if ($this->tool()->platform()->hasDemoMode()) {
$xml = simplexml_load_file(Mage::getBaseDir() . "/aitmodules.xml");
$link = (string) $xml->modules->{$aModule}['key'];
if ($link == '') {
$link = $this->tool()->getAitocUrl();
}
$message = Mage::helper('aitsys')->__("The extension is already enabled on this Demo Magento installation and can't be disabled for security reasons. Please proceed to the next step outlined in the extension's <a href='%s' target='_blank'>User Manual</a> to see how it works.", $link);
$isDemo = true;
} elseif (defined('COMPILER_INCLUDE_PATH')) {
$compilerUrl = version_compare(Mage::getVersion(), '1.5.0.0', '>=') ? Mage::helper('adminhtml')->getUrl('adminhtml/compiler_process/index/') : Mage::helper('adminhtml')->getUrl('compiler/process/index/');
$message = Mage::helper('aitsys')->__('Before activating or deactivating the extension please turn off the compiler at <br /><a href="%s">System > Tools > Compilation</a>', $compilerUrl);
$messageType = 'warning-msg';
} elseif (!$module->getInfo()->isMagentoCompatible()) {
$message = Mage::helper('aitsys/strings')->getString('ER_ENT_HASH');
} elseif (!$module->getAccess()) {
$message = Mage::helper('aitsys')->__('File does not have write permissions: %s', $aModule['file']);
$messageType = 'error-msg';
}
if ($module->getInfo()->getSerial()) {
$info = 'S/N: ' . $module->getInfo()->getSerial();
}
if ($aModule['key'] == 'Aitoc_Common') {
$info = 'Used by other AITOC\'s modules. Do not disable.';
}
if ($message && $messageType != 'notice-msg' || $isDemo) {
$field = $fieldset->addField('ignore_' . $aModule['key'], 'note', array('name' => 'ignore[' . $aModule['key'] . ']', 'label' => $label, 'info' => empty($info) ? '' : $info, 'note' => '<ul class="messages"><li class="' . $messageType . '"><ul><li>' . $message . '</li></ul></li></ul>', 'module' => $module));
if (!$isDemo) {
$field->setRenderer($this->_elementRenderer);
}
return;
}
$fieldset->addField('hidden_enable_' . $aModule['key'], 'hidden', array('name' => 'enable[' . $aModule['key'] . ']', 'value' => 0));
$fieldset->addField('enable_' . $aModule['key'], 'checkbox', array('name' => ($module->getAccess() ? 'enable' : 'ignore') . '[' . $aModule['key'] . ']', 'label' => $label, 'value' => 1, 'checked' => $aModule['value'], 'note' => $message ? '<ul class="messages"><li class="' . $messageType . '"><ul><li>' . $message . '</li></ul></li></ul>' : '', 'info' => empty($info) ? '' : $info, 'module' => $module))->setRenderer($this->_elementRenderer);
}
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:48,代码来源:Form.php
示例8: populateFieldset
/**
* Populate form fieldset with group data
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
*/
public function populateFieldset(Varien_Data_Form_Element_Fieldset $fieldset)
{
$originalData = array();
foreach ($this->_data as $key => $value) {
if (!is_array($value)) {
$originalData[$key] = $value;
}
}
$fieldset->setOriginalData($originalData);
}
开发者ID:,项目名称:,代码行数:15,代码来源:
示例9: _getFieldHtml
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param string $id
* @param string $status
* @return string
*/
protected function _getFieldHtml($fieldset, $id, $status)
{
$configData = $this->getConfigData();
$path = 'sales/order_statuses/status_' . $id;
//TODO: move as property of form
$data = isset($configData[$path]) ? $configData[$path] : array();
$e = $this->_getDummyElement();
$field = $fieldset->addField($id, 'text', array('name' => 'groups[order_statuses][fields][status_' . $id . '][value]', 'label' => $status, 'value' => isset($data['value']) ? $data['value'] : $status, 'default_value' => isset($data['default_value']) ? $data['default_value'] : '', 'old_value' => isset($data['old_value']) ? $data['old_value'] : '', 'inherit' => isset($data['inherit']) ? $data['inherit'] : '', 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e)))->setRenderer($this->_getFieldRenderer());
return $field->toHtml();
}
开发者ID:nickimproove,项目名称:magento2,代码行数:16,代码来源:Statuses.php
示例10: _addFieldsToFieldset
/**
* This method makes life a little easier for us by pre-populating
* fields with $_POST data where applicable and wrapping our post data
* in 'brandData' so that we can easily separate all relevant information
* in the controller. You could of course omit this method entirely
* and call the $fieldset->addField() method directly.
* @return self
*/
protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
{
foreach ($fields as $name => $_data) {
// Wrap all fields with brandData group.
$_data['name'] = "configData[{$name}]";
// Generally, label and title are always the same.
$_data['title'] = $_data['label'];
// If no new value exists, use the existing data.
if (!array_key_exists('value', $_data)) {
$_data['value'] = $this->_getValue()->getData($name);
}
if ($name == "test_mode") {
$_data['checked'] = $this->_getValue()->getData($name);
}
// Finally, call vanilla functionality to add field.
$fieldset->addField($name, $_data['input'], $_data);
}
return $this;
}
开发者ID:agentelinux,项目名称:omise-magento,代码行数:27,代码来源:Form.php
示例11: _addFieldsToFieldset
/**
* This method makes life a little easier for us by pre-populating
* fields with $_POST data where applicable and wraps our post data in
* 'brandData' so we can easily separate all relevant information in
* the controller. You can of course omit this method entirely and call
* the $fieldset->addField() method directly.
*/
protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
{
$requestData = new Varien_Object($this->getRequest()->getPost('mappingData'));
foreach ($fields as $name => $_data) {
if ($requestValue = $requestData->getData($name)) {
$_data['value'] = $requestValue;
}
// wrap all fields with brandData group
$_data['name'] = "mappingData[{$name}]";
// generally label and title always the same
$_data['title'] = $_data['label'];
// if no new value exists, use existing brand data
if (!array_key_exists('value', $_data)) {
$_data['value'] = $this->_getBrand()->getData($name);
}
// finally call vanilla functionality to add field
$fieldset->addField($name, $_data['input'], $_data);
}
return $this;
}
开发者ID:vesviet,项目名称:dellocal,代码行数:27,代码来源:Form.php
示例12: _addFieldsToFieldset
/**
* This method makes life a little easier for us by pre-populating
* fields with $_POST data where applicable and wrapping our post data
* in 'commentData' so that we can easily separate all relevant information
* in the controller. You could of course omit this method entirely
* and call the $fieldset->addField() method directly.
*/
protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
{
$requestData = new Varien_Object($this->getRequest()->getPost('commentData'));
foreach ($fields as $name => $_data) {
if ($requestValue = $requestData->getData($name)) {
$_data['value'] = $requestValue;
}
// Wrap all fields with commentData group.
$_data['name'] = "commentData[{$name}]";
// Generally, label and title are always the same.
$_data['title'] = $_data['label'];
// If no new value exists, use the existing comment data.
if (!array_key_exists('value', $_data)) {
$_data['value'] = $this->_getComment()->getData($name);
}
// Finally, call vanilla functionality to add field.
$fieldset->addField($name, $_data['input'], $_data);
}
return $this;
}
开发者ID:kamilpolcode,项目名称:magento,代码行数:27,代码来源:Form.php
示例13: _prepareVisibleFields
/**
* Prepare form fieldset
* All fields are visible
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
*
* @return Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form
*/
protected function _prepareVisibleFields(Varien_Data_Form_Element_Fieldset $fieldset)
{
$fieldset->addField('sender', 'text', array('name' => $this->_getFieldName('sender'), 'label' => Mage::helper('sales')->__('From'), 'required' => $this->getMessage()->getMessage() ? true : false));
$fieldset->addField('recipient', 'text', array('name' => $this->_getFieldName('recipient'), 'label' => Mage::helper('sales')->__('To'), 'required' => $this->getMessage()->getMessage() ? true : false));
$fieldset->addField('message', 'textarea', array('name' => $this->_getFieldName('message'), 'label' => Mage::helper('sales')->__('Message'), 'rows' => '5', 'cols' => '20'));
return $this;
}
开发者ID:hirentricore,项目名称:devmagento,代码行数:15,代码来源:Form.php
示例14: initFields
/**
* Init fieldset fields
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Varien_Simplexml_Element $group
* @param Varien_Simplexml_Element $section
* @param string $fieldPrefix
* @param string $labelPrefix
* @return Mage_Adminhtml_Block_System_Config_Form
*/
public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
{
if (!$this->_configDataObject) {
$this->_initObjects();
}
// Extends for config data
$configDataAdditionalGroups = array();
foreach ($group->fields as $elements) {
$elements = (array) $elements;
// sort either by sort_order or by child node values bypassing the sort_order
if ($group->sort_fields && $group->sort_fields->by) {
$fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
} else {
usort($elements, array($this, '_sortForm'));
}
foreach ($elements as $element) {
if (!$this->_canShowField($element)) {
continue;
}
if ((string) $element->getAttribute('type') == 'group') {
$this->_initGroup($fieldset->getForm(), $element, $section, $fieldset);
continue;
}
/**
* Look for custom defined field path
*/
$path = (string) $element->config_path;
if (empty($path)) {
$path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
} elseif (strrpos($path, '/') > 0) {
// Extend config data with new section group
$groupPath = substr($path, 0, strrpos($path, '/'));
if (!isset($configDataAdditionalGroups[$groupPath])) {
$this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData);
$configDataAdditionalGroups[$groupPath] = true;
}
}
$data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData);
if ($element->frontend_model) {
$fieldRenderer = Mage::getBlockSingleton((string) $element->frontend_model);
} else {
$fieldRenderer = $this->_defaultFieldRenderer;
}
$fieldRenderer->setForm($this);
$fieldRenderer->setConfigData($this->_configData);
$helperName = $this->_configFields->getAttributeModule($section, $group, $element);
$fieldType = (string) $element->frontend_type ? (string) $element->frontend_type : 'text';
$name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $element->getName() . '][value]';
$label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $element->label);
$hint = (string) $element->hint ? Mage::helper($helperName)->__((string) $element->hint) : '';
if ($element->backend_model) {
$model = Mage::getModel((string) $element->backend_model);
if (!$model instanceof Mage_Core_Model_Config_Data) {
Mage::throwException('Invalid config field backend model: ' . (string) $element->backend_model);
}
$model->setPath($path)->setValue($data)->setWebsite($this->getWebsiteCode())->setStore($this->getStoreCode())->afterLoad();
$data = $model->getValue();
}
$comment = $this->_prepareFieldComment($element, $helperName, $data);
$tooltip = $this->_prepareFieldTooltip($element, $helperName);
$id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName();
if ($element->depends) {
foreach ($element->depends->children() as $dependent) {
/* @var $dependent Mage_Core_Model_Config_Element */
if (isset($dependent->fieldset)) {
$dependentFieldGroupName = (string) $dependent->fieldset;
if (!isset($this->_fieldsets[$dependentFieldGroupName])) {
$dependentFieldGroupName = $group->getName();
}
} else {
$dependentFieldGroupName = $group->getName();
}
$dependentFieldNameValue = $dependent->getName();
$dependentFieldGroup = $dependentFieldGroupName == $group->getName() ? $group : $this->_fieldsets[$dependentFieldGroupName]->getGroup();
$dependentId = $section->getName() . '_' . $dependentFieldGroupName . '_' . $fieldPrefix . $dependentFieldNameValue;
$shouldBeAddedDependence = true;
$dependentValue = (string) (isset($dependent->value) ? $dependent->value : $dependent);
if (isset($dependent['separator'])) {
$dependentValue = explode((string) $dependent['separator'], $dependentValue);
}
$dependentFieldName = $fieldPrefix . $dependent->getName();
$dependentField = $dependentFieldGroup->fields->{$dependentFieldName};
/*
* If dependent field can't be shown in current scope and real dependent config value
* is not equal to preferred one, then hide dependence fields by adding dependence
* based on not shown field (not rendered field)
*/
if (!$this->_canShowField($dependentField)) {
$dependentFullPath = $section->getName() . '/' . $dependentFieldGroupName . '/' . $fieldPrefix . $dependent->getName();
$dependentValueInStore = Mage::getStoreConfig($dependentFullPath, $this->getStoreCode());
//.........这里部分代码省略.........
开发者ID:monkviper,项目名称:magento-lite,代码行数:101,代码来源:Form.php
示例15: _addEditableSelectField
protected function _addEditableSelectField(Varien_Data_Form_Element_Fieldset $fieldset, $field, $name, array $options, $required = true)
{
$helper = $this->getAction()->getModuleHelper();
$fieldset->addField($field, 'select', array('name' => $this->_getFormElementName($field), 'label' => $helper->__($name), 'title' => $helper->__($name), 'value' => $this->_getValueIfObjectIsSet($field), 'values' => $options, 'required' => $required));
}
开发者ID:zztimur,项目名称:reverb-magento,代码行数:5,代码来源:Form.php
示例16: _addField
/**
* Add a field to the form or fieldset
* Form and fieldset have same abstract
*
* @param Varien_Data_Form|Varien_Data_Form_Element_Fieldset $formOrFieldset
* @param string $elementName
* @param array $options
* @param string $type
* @return Varien_Data_Form_Element_Abstract
*/
protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text')
{
$options = array_merge($options, array('name' => $elementName, 'label' => $this->_profile->getFieldLabel($elementName), 'note' => $this->_profile->getFieldComment($elementName), 'disabled' => $this->_isReadOnly));
if (in_array($elementName, array('period_unit', 'period_frequency'))) {
$options['required'] = true;
}
return $formOrFieldset->addField($elementName, $type, $options);
}
开发者ID:relue,项目名称:magento2,代码行数:18,代码来源:Form.php
示例17: addImage
/**
* Add image uploader to fieldset
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param string $fieldName
* @param string $title
* @param string $note
* @param string $default
* @param boolean $required
*/
public function addImage($fieldset, $fieldName, $title, $note = '', $default = '', $required = false)
{
$fieldset->addField($fieldName, 'image', array('name' => $fieldName, 'label' => $title, 'note' => !empty($note) ? $note : null, 'required' => $required));
}
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:14,代码来源:Submission.php
示例18: addFont
/**
* Add font selector to fieldset
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param string $fieldPrefix
* @param string $title
*/
public function addFont($fieldset, $fieldPrefix, $title)
{
$element = $fieldset->addField($fieldPrefix, 'font', array('name' => $fieldPrefix, 'label' => $title));
$element->initFields(array('name' => $fieldPrefix, 'fontNames' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontList(), 'fontSizes' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontSizes()));
}
开发者ID:hirentricore,项目名称:devmagento,代码行数:12,代码来源:Form.php
示例19: initFields
/**
* Init fieldset fields
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Varien_Simplexml_Element $group
* @param Varien_Simplexml_Element $section
* @param string $fieldPrefix
* @param string $labelPrefix
* @return Mage_Adminhtml_Block_System_Config_Form
*/
public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
{
foreach ($group->fields as $elements) {
$elements = (array) $elements;
// sort either by sort_order or by child node values bypassing the sort_order
if ($group->sort_fields && $group->sort_fields->by) {
$fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
} else {
usort($elements, array($this, '_sortForm'));
}
foreach ($elements as $e) {
if (!$this->_canShowField($e)) {
continue;
}
$path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName();
$id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName();
if (isset($this->_configData[$path])) {
$data = $this->_configData[$path];
$inherit = false;
} else {
$data = $this->_configRoot->descend($path);
$inherit = true;
}
if ($e->frontend_model) {
$fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
} else {
$fieldRenderer = $this->_defaultFieldRenderer;
}
$fieldRenderer->setForm($this);
$fieldRenderer->setConfigData($this->_configData);
$helperName = $this->_configFields->getAttributeModule($section, $group, $e);
$fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
$name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]';
$label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label);
$comment = (string) $e->comment ? Mage::helper($helperName)->__((string) $e->comment) : '';
if ($e->backend_model) {
$model = Mage::getModel((string) $e->backend_model);
if (!$model instanceof Mage_Core_Model_Config_Data) {
Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model);
}
$model->setPath($path)->setValue($data)->afterLoad();
$data = $model->getValue();
}
$field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website)));
if (isset($e->validate)) {
$field->addClass($e->validate);
}
if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) {
$field->setCanBeEmpty(true);
}
$field->setRenderer($fieldRenderer);
if ($e->source_model) {
$sourceModel = Mage::getSingleton((string) $e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
}
}
}
return $this;
}
开发者ID:Rinso,项目名称:magento-mirror,代码行数:72,代码来源:Form.php
示例20: _addNewUserPasswordFields
/**
* Add password creation fields in new user form
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
*/
protected function _addNewUserPasswordFields(Varien_Data_Form_Element_Fieldset $fieldset)
{
$fieldset->addField('password', 'password', array('name' => 'password', 'label' => Mage::helper('Mage_User_Helper_Data')->__('Password'), 'id' => 'customer_pass', 'title' => Mage::helper('Mage_User_Helper_Data')->__('Password'), 'class' => 'input-text required-entry validate-admin-password', 'required' => true));
$fieldset->addField('confirmation', 'password', array('name' => 'password_confirmation', 'label' => Mage::helper('Mage_User_Helper_Data')->__('Password Confirmation'), 'id' => 'confirmation', 'title' => Mage::helper('Mage_User_Helper_Data')->__('Password Confirmation'), 'class' => 'input-text required-entry validate-cpassword', 'required' => true));
}
开发者ID:nemphys,项目名称:magento2,代码行数:10,代码来源:Main.php
注:本文中的Varien_Data_Form_Element_Fieldset类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论