本文整理汇总了PHP中Varien_Data_Form_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Abstract类的具体用法?PHP Varien_Data_Form_Abstract怎么用?PHP Varien_Data_Form_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Data_Form_Abstract类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('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;
}
开发者ID:pcuervo,项目名称:gadfy,代码行数:42,代码来源:Abstract.php
示例2: addOnChangeToFormElements
/**
* Recursively walk through container (form or fieldset)
* and add to each element new onChange method.
* Element will be skipped if its type passed in $excludeTypes parameter.
*
* @param Varien_Data_Form_Abstract $container
* @param string $onChange
* @param string|array $excludeTypes
*/
public function addOnChangeToFormElements($container, $onChange, $excludeTypes = array('hidden'))
{
if (!is_array($excludeTypes)) {
$excludeTypes = array($excludeTypes);
}
foreach ($container->getElements() as $element) {
if ($element->getType() == 'fieldset') {
$this->addOnChangeToFormElements($element, $onChange, $excludeTypes);
} else {
if (!in_array($element->getType(), $excludeTypes)) {
if ($element->hasOnchange()) {
$onChangeBefore = $element->getOnchange() . ';';
} else {
$onChangeBefore = '';
}
$element->setOnchange($onChangeBefore . $onChange);
}
}
}
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:29,代码来源:Data.php
示例3: _addElementTypes
/**
* Add new element type
*
* @param Varien_Data_Form_Abstract $baseElement
*/
protected function _addElementTypes(Varien_Data_Form_Abstract $baseElement)
{
$types = $this->_getAdditionalElementTypes();
foreach ($types as $code => $className) {
$baseElement->addType($code, $className);
}
}
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:12,代码来源:Form.php
示例4: assertFieldNotExist
/**
* Assert form field not exist
*
* @param Varien_Data_Form_Abstract $form
* @param string $elementId
*/
public static function assertFieldNotExist(Varien_Data_Form_Abstract $form, $elementId)
{
$field = $form->getElements()->searchById($elementId);
if ($field) {
self::fail("Element with id '{$elementId}' was found in form");
}
}
开发者ID:jsiefer,项目名称:mage-mock,代码行数:13,代码来源:FormTest.php
示例5: _initGroup
/**
* Initialize config field group
*
* @param Mage_Backend_Model_Config_Structure_Element_Group $group
* @param Mage_Backend_Model_Config_Structure_Element_Section $section
* @param Varien_Data_Form $form
*/
protected function _initGroup(Mage_Backend_Model_Config_Structure_Element_Group $group, Mage_Backend_Model_Config_Structure_Element_Section $section, Varien_Data_Form_Abstract $form)
{
$frontendModelClass = $group->getFrontendModel();
$fieldsetRenderer = $frontendModelClass ? Mage::getBlockSingleton($frontendModelClass) : $this->_fieldsetRenderer;
$fieldsetRenderer->setForm($this);
$fieldsetRenderer->setConfigData($this->_configData);
$fieldsetRenderer->setGroup($group);
$fieldsetConfig = array('legend' => $group->getLabel(), 'comment' => $group->getComment(), 'expanded' => $group->isExpanded());
$fieldset = $form->addFieldset($this->_generateElementId($group->getPath()), $fieldsetConfig);
$fieldset->setRenderer($fieldsetRenderer);
$group->populateFieldset($fieldset);
$this->_addElementTypes($fieldset);
$dependencies = $group->getDependencies($this->getStoreCode());
$elementName = $this->_generateElementName($group->getPath());
$elementId = $this->_generateElementId($group->getPath());
$this->_populateDependenciesBlock($dependencies, $elementId, $elementName);
if ($group->shouldCloneFields()) {
$cloneModel = $group->getCloneModel();
foreach ($cloneModel->getPrefixes() as $prefix) {
$this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
}
} else {
$this->initFields($fieldset, $group, $section);
}
$this->_fieldsets[$group->getId()] = $fieldset;
}
开发者ID:,项目名称:,代码行数:33,代码来源:
示例6: add
/**
* Add element to collection
*
* @todo get it straight with $after
* @param Varien_Data_Form_Element_Abstract $element
* @param boolean|'^'|string $after
* @return Varien_Data_Form_Element_Abstract
*/
public function add(Varien_Data_Form_Element_Abstract $element, $after = false)
{
// Set the Form for the node
if ($this->_container->getForm() instanceof Varien_Data_Form) {
$element->setContainer($this->_container);
$element->setForm($this->_container->getForm());
}
if ($after === false) {
$this->_elements[] = $element;
} elseif ($after === '^') {
array_unshift($this->_elements, $element);
} elseif (is_string($after)) {
$newOrderElements = array();
foreach ($this->_elements as $index => $currElement) {
if ($currElement->getId() == $after) {
$newOrderElements[] = $currElement;
$newOrderElements[] = $element;
$this->_elements = array_merge($newOrderElements, array_slice($this->_elements, $index + 1));
return $element;
}
$newOrderElements[] = $currElement;
}
$this->_elements[] = $element;
}
return $element;
}
开发者ID:hirentricore,项目名称:devmagento,代码行数:34,代码来源:Collection.php
示例7: addElement
/**
* Add form element
*
* @param Varien_Data_Form_Element_Abstract $element
* @return Varien_Data_Form
*/
public function addElement(Varien_Data_Form_Element_Abstract $element, $after = false)
{
$this->checkElementId($element->getId());
parent::addElement($element, $after);
$this->addElementToCollection($element);
return $this;
}
开发者ID:arslbbt,项目名称:mangentovies,代码行数:13,代码来源:Form.php
示例8: serialize
public function serialize($attributes = array(), $valueSeparator = '=', $fieldSeparator = ' ', $quote = '"')
{
if (in_array('disabled', $attributes) && !empty($this->_data['disabled'])) {
$this->_data['disabled'] = 'disabled';
} else {
unset($this->_data['disabled']);
}
if (in_array('checked', $attributes) && !empty($this->_data['checked'])) {
$this->_data['checked'] = 'checked';
} else {
unset($this->_data['checked']);
}
return parent::serialize($attributes, $valueSeparator, $fieldSeparator, $quote);
}
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:14,代码来源:Abstract.php
示例9: removeField
public function removeField($elementId)
{
$this->getForm()->removeField($elementId);
return parent::removeField($elementId);
}
开发者ID:arslbbt,项目名称:mangentovies,代码行数:5,代码来源:Abstract.php
注:本文中的Varien_Data_Form_Abstract类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论