本文整理匯總了PHP中Varien_Data_Form_Abstract::addField方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Form_Abstract::addField方法的具體用法?PHP Varien_Data_Form_Abstract::addField怎麽用?PHP Varien_Data_Form_Abstract::addField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Data_Form_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Abstract::addField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _addAttributesToForm
/**
* Add rendering EAV attributes to Form element
*
* @param array|Varien_Data_Collection $attributes
* @param Varien_Data_Form_Abstract $form
* @return Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract
*/
protected function _addAttributesToForm($attributes, Varien_Data_Form_Abstract $form)
{
// add additional form types
$types = $this->_getAdditionalFormElementTypes();
foreach ($types as $type => $className) {
$form->addType($type, $className);
}
$renderers = $this->_getAdditionalFormElementRenderers();
foreach ($attributes as $attribute) {
/** @var $attribute Mage_Customer_Model_Attribute */
$attribute->setStoreId(Mage::getSingleton('request4quote/adminhtml_session_quote')->getStoreId());
$inputType = $attribute->getFrontend()->getInputType();
if ($inputType) {
$element = $form->addField($attribute->getAttributeCode(), $inputType, array('name' => $attribute->getAttributeCode(), 'label' => $this->__($attribute->getStoreLabel()), 'class' => $attribute->getFrontend()->getClass(), 'required' => $attribute->getIsRequired()));
if ($inputType == 'multiline') {
$element->setLineCount($attribute->getMultilineCount());
}
$element->setEntityAttribute($attribute);
$this->_addAdditionalFormElementData($element);
if (!empty($renderers[$attribute->getAttributeCode()])) {
$element->setRenderer($renderers[$attribute->getAttributeCode()]);
}
if ($inputType == 'select' || $inputType == 'multiselect') {
$element->setValues($attribute->getFrontend()->getSelectOptions());
} else {
if ($inputType == 'date') {
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
$element->setFormat($format);
}
}
}
}
return $this;
}