/** * {@inheritDoc} */ public function setData($data) { if ($this->mode === self::GROUP) { parent::setData($data); } else { Field::setData($data); } }
public function setData($collection) { if (!is_array($collection) && !$collection instanceof \Traversable) { throw new UnexpectedTypeException('The data must be an array'); } foreach ($collection as $name => $value) { $this->add($this->newField($name, $name)); } parent::setData($collection); }
public function setData($collection) { if (!is_array($collection) && !$collection instanceof \Traversable) { throw new UnexpectedTypeException('The data passed to the CollectionField must be an array or a Traversable'); } foreach ($this as $name => $field) { if (!$this->getOption('modifiable') || '$$key$$' != $name) { $this->remove($name); } } foreach ($collection as $name => $value) { $this->add($this->newField($name, $name)); } parent::setData($collection); }
public function testGetDataReturnsObject() { $group = new FieldGroup('author'); $object = new \stdClass(); $group->setData($object); $this->assertEquals($object, $group->getData()); }