public function testPushAndUnshift() { $composite = new CompositeField(new TextField('Middle')); $composite->push(new TextField('End')); /* There are now 2 fields in the set */ $this->assertEquals(2, $composite->getChildren()->Count()); /* The most recently added field is at the end of the set */ $this->assertEquals('End', $composite->getChildren()->Last()->getName()); $composite->unshift(new TextField('Beginning')); /* There are now 3 fields in the set */ $this->assertEquals(3, $composite->getChildren()->Count()); /* The most recently added field is at the beginning of the set */ $this->assertEquals('Beginning', $composite->getChildren()->First()->getName()); }
/** * Add a new child field to the beginning of the set. */ public function unshift(FormField $field) { parent::unshift($field); $field->setTabSet($this); }
/** * Add a new child field to the beginning of the set. * * @param FormField $field */ public function unshift(FormField $field) { if ($field instanceof Tab || $field instanceof TabSet) { $field->setTabSet($this); } parent::unshift($field); }