本文整理匯總了PHP中Varien_Data_Form_Abstract::getElements方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Form_Abstract::getElements方法的具體用法?PHP Varien_Data_Form_Abstract::getElements怎麽用?PHP Varien_Data_Form_Abstract::getElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Data_Form_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Abstract::getElements方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
}
}
}
示例2: 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");
}
}