Example #1
0
 /**
  * Removes the element from this container
  *
  * If the reference object is not given, the element will be appended.
  *
  * @param    HTML_QuickForm2_Node     Element to remove
  * @return   HTML_QuickForm2_Node     Removed object
  */
 public function removeChild(HTML_QuickForm2_Node $element)
 {
     if ($element->getContainer() !== $this) {
         throw new HTML_QuickForm2_NotFoundException("Element with name '" . $element->getName() . "' was not found");
     }
     foreach ($this as $key => $child) {
         if ($child === $element) {
             unset($this->elements[$key]);
             $element->setContainer(null);
             break;
         }
     }
     return $element;
 }
Example #2
0
 /**
  * Appends an element to the container
  *
  * If the element was previously added to the container or to another
  * container, it is first removed there.
  *
  * @param    HTML_QuickForm2_Node     Element to add
  * @return   HTML_QuickForm2_Node     Added element
  * @throws   HTML_QuickForm2_InvalidArgumentException
  */
 public function appendChild(HTML_QuickForm2_Node $element)
 {
     if (null !== ($container = $element->getContainer())) {
         $container->removeChild($element);
     }
     // Element can be renamed only after being removed from container
     $this->renameChild($element);
     $element->setContainer($this);
     $this->elements[] = $element;
     return $element;
 }