/** * Adds a child to the composite. * * @param T_CompositeLeaf $child child to add * @param string $key optional key to refer to composite. * @return T_Form_MultiStep fluent interface */ function addChild(T_CompositeLeaf $child, $key = null) { if ($child instanceof T_Form_Step) { if (!isset($key)) { $key = $child->getAlias(); } $this->steps[$key] = $child; reset($this->steps); // keep array pointer at start $this->init(); return $this; } else { return parent::addChild($child, $key); } }
/** * Add a child element. * * @param T_CompositeLeaf $child child input element object. * @return T_Form_Group fluent interface */ function addChild(T_CompositeLeaf $child, $key = null) { if (!$key) { $key = $child->getAlias(); } $i = 1; foreach ($this->children as $group) { $block = clone $child; $block->accept(new T_Form_SuffixAlias("_{$i}")); $group->addChild($block, $key); // ^ cloned and alias suffixed, and added to each group with // original alias $i++; } return $this; }
/** * Add a child element. * * Can override default behaviour by specifying a named key for the child, * otherwise the element alias is used by default. * * @param T_CompositeLeaf $child child input element object. * @return T_Form_Group fluent interface */ function addChild(T_CompositeLeaf $child, $key = null) { if (isset($key)) { $this->children[$key] = $child; } else { $this->children[$child->getAlias()] = $child; } return $this; }