/**
  * 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
0
 /**
  * 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");
     }
 }