本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::addField方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::addField方法的具体用法?PHP Varien_Data_Form_Element_Abstract::addField怎么用?PHP Varien_Data_Form_Element_Abstract::addField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::addField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$test = $this->_testApi();
if ($test !== false) {
$element->addType('tokenbase_apitest', 'ParadoxLabs_TokenBase_Block_Adminhtml_Config_Renderer_ApiTest');
$field = $element->addField($this->_code . '_apitest', 'tokenbase_apitest', array('name' => $this->_code . '_apitest', 'label' => 'API Test Results', 'value' => $test))->setRenderer($this->_getRenderer());
return $field->toHtml();
}
}
示例2: addField
/**
* Enter description here...
*
* @param string $elementId
* @param string $type
* @param array $config
* @param boolean $after
* @return Varien_Data_Form_Element_Abstract
*/
public function addField($elementId, $type, $config, $after = false)
{
$element = parent::addField($elementId, $type, $config, $after);
if ($renderer = Varien_Data_Form::getFieldsetElementRenderer()) {
$element->setRenderer($renderer);
}
return $element;
}
示例3: _createLabel
/**
* Create Label and Return it
*
* @param Varien_Data_Form_Element_Abstract $fieldset
* @param Varien_Object $element
* @param array $groupData
* @param $section
* @param $group
*
* @return string|Varien_Data_Form_Element_Abstract
*/
protected function _createLabel(Varien_Data_Form_Element_Abstract $fieldset, Varien_Object $element, array $groupData, $section, $group)
{
$configCode = 'bronto_email_templates_label_' . $section . '_' . $group;
$data = $groupData['parts'][2]['title'];
$inherit = false;
// Get field Renderer
if ($element->frontend_model) {
$fieldRenderer = Mage::getBlockSingleton((string) $element->frontend_model);
} else {
$fieldRenderer = $this->_getFieldRenderer();
}
// Define Type, Name, and Label
$fieldType = 'label';
$label = $data;
try {
// Select Field for Existing attributes.
$field = $fieldset->addField($configCode, $fieldType, array('label' => $label, 'inherit' => $inherit, 'field_config' => $element, 'scope' => $this->getForm()->getScope(), 'scopeId' => $this->getForm()->getScopeId(), 'can_use_default_value' => $this->getForm()->canUseDefaultValue((int) $element->show_in_default), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int) $element->show_in_website)));
// Set Field Renderer
$field->setRenderer($fieldRenderer);
} catch (Exception $e) {
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
return '';
}
return $field;
}
示例4: _createField
/**
* Create Field and Return it
*
* @param Varien_Data_Form_Element_Abstract $fieldset
* @param Varien_Object $e
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param string $fieldStep
*
* @return Varien_Data_Form_Element_Abstract
*/
protected function _createField(Varien_Data_Form_Element_Abstract $fieldset, Varien_Object $e, Mage_Eav_Model_Entity_Attribute $attribute, $fieldStep = 'standard')
{
// Get Config Data
$configData = $this->getConfigData();
if ('' == $attribute->getFrontendLabel()) {
return false;
}
// Define Attribute Code
$attributeCode = $attribute->getAttributeCode();
$attributeCode = $fieldStep == 'newfield' ? "{$attributeCode}_dynamic_new" : $attributeCode;
// Get Attribute Data and Inheritance
$path = $this->_configPath . $attributeCode;
if (isset($configData[$path])) {
$data = $configData[$path];
$inherit = false;
} else {
$data = (string) Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
$inherit = true;
}
// Get field Renderer
if ($e->frontend_model) {
$fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
} else {
$fieldRenderer = $this->_getFieldRenderer();
}
// Define Type, Name, and Label
$fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
$name = str_replace('_attrCode_', $attributeCode, $this->_fieldNameTemplate);
$label = $fieldStep == 'newfield' ? "" : $attribute->getFrontendLabel();
// Pass through backend model in case it needs to modify value
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();
}
// Pre-populate New field with label text
if ('newfield' == $fieldStep && '' == $data) {
$data = $attribute->getFrontendLabel();
}
// Select Field for Existing attributes.
$field = $fieldset->addField($attributeCode, $fieldType, array('name' => $name, 'label' => $label, 'value' => $data === 0 ? '' : $data, 'inherit' => $fieldStep == 'newfield' ? false : $inherit, 'field_config' => $e, 'scope' => $this->getForm()->getScope(), 'scopeId' => $this->getForm()->getScopeId(), 'scope_label' => '[STORE VIEW]', 'can_use_default_value' => $this->getForm()->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int) $e->show_in_website), 'can_use_store_value' => $this->getForm()->canUseWebsiteValue((int) $e->show_in_store)));
// Add Validation
if ($e->validate) {
$field->addClass($e->validate);
}
// Determine if value can be empty
if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) {
$field->setCanBeEmpty(true);
}
// Set Field Renderer
$field->setRenderer($fieldRenderer);
// Use Source Model to define available options
if ($e->source_model) {
$sourceModel = Mage::getSingleton((string) $e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
$field->setValues($sourceModel->toOptionArray());
}
return $field;
}
示例5: _getFieldHtml
/**
* Get field html
*
* @param Varien_Data_Form_Element_Abstract $fieldset
* @param string $notificationType
* @return string
*/
protected function _getFieldHtml($fieldset, $notificationType)
{
$configData = $this->getConfigData();
$path = Wfs_DisableEmails_Model_Email_Template::XML_PATH_PREFIX . $notificationType['value'];
if (isset($configData[$path])) {
$data = $configData[$path];
$inherit = false;
} else {
$data = (int) (string) $this->getForm()->getConfigRoot()->descend($path);
$inherit = true;
}
$e = $this->_getDummyElement();
$field = $fieldset->addField('notify_' . $notificationType['value'], 'select', array('name' => 'groups[wfs_disable_emails][fields][' . $notificationType['value'] . '][value]', 'label' => $notificationType['label'], 'value' => $data, 'values' => $this->_getValues(), 'inherit' => $inherit, 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e)))->setRenderer($this->_getFieldRenderer());
return $field->toHtml();
}