/** * Add new element to group. * * @param \DeForm\Element\ElementInterface $element * @return self * @throw \InvalidArgumentException */ public function addElement(ElementInterface $element) { if (false === $element instanceof RadioElement) { throw new \InvalidArgumentException('Only instance of RadioElement object can be added.'); } if ($this->countElements() > 0 && $element->getName() !== $this->getName()) { throw new \InvalidArgumentException('Attribute input[name] is invalid.'); } $this->elements[] = $element; return $this; }