Nette\Forms\ControlGroup::add PHP Метод

add() публичный Метод

public add ( $items ) : self
Результат self
    public function add(...$items)
    {
        foreach ($items as $item) {
            if ($item instanceof IControl) {
                $this->controls->attach($item);
            } elseif ($item instanceof Container) {
                foreach ($item->getComponents() as $component) {
                    $this->add($component);
                }
            } elseif ($item instanceof \Traversable || is_array($item)) {
                $this->add(...$item);
            } else {
                $type = is_object($item) ? get_class($item) : gettype($item);
                throw new Nette\InvalidArgumentException("IControl or Container items expected, {$type} given.");
            }
        }
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Adds the specified component to the IComponentContainer.
  * @param  IComponent
  * @param  string
  * @param  string
  * @return void
  * @throws Nette\InvalidStateException
  */
 public function addComponent(Nette\ComponentModel\IComponent $component, $name, $insertBefore = NULL)
 {
     parent::addComponent($component, $name, $insertBefore);
     if ($this->currentGroup !== NULL && $component instanceof IControl) {
         $this->currentGroup->add($component);
     }
 }
All Usage Examples Of Nette\Forms\ControlGroup::add