Exemplo n.º 1
0
 public function testGetIterator()
 {
     $group = $this->getMock('Message\\Cog\\Field\\Group');
     $fields = new RepeatableContainer($group);
     $this->assertInstanceOf('\\Traversable', $fields->getIterator());
 }
Exemplo n.º 2
0
 /**
  * Add a repeatable group of fields to the form.
  *
  * @param string              $name  Name of the repeatable group
  * @param RepeatableContainer $group The repeatable group
  */
 protected function _addRepeatableGroup($name, RepeatableContainer $group)
 {
     $dynamic = new DynamicFormType();
     // Add each field as a collection
     foreach ($group->getFields() as $field) {
         $dynamic->add($field->getName(), $field->getFormType(), $field->getFieldOptions());
     }
     // Add the form to the main form
     $this->_builder->add($name, 'collection', ['label' => $group->getLabel(), 'type' => $dynamic, 'allow_add' => true, 'allow_delete' => true, 'data' => $this->_getDefaultValuesForRepeatableGroup($group)]);
 }