/** * {@inheritDoc} */ public function setData($data) { if ($this->mode === self::GROUP) { parent::setData($data); } else { Field::setData($data); } }
/** * Initializes the field group with an object to operate on * * @see FieldInterface */ public function setData($data) { if (empty($data)) { if ($this->dataConstructor) { $constructor = $this->dataConstructor; $data = $constructor(); } else { if ($this->dataClass) { $class = $this->dataClass; $data = new $class(); } } } parent::setData($data); // get transformed data and pass its values to child fields $data = $this->getTransformedData(); if (!empty($data) && !is_array($data) && !is_object($data)) { throw new \InvalidArgumentException(sprintf('Expected argument of type object or array, %s given', gettype($data))); } if (!empty($data)) { if ($this->dataClass && !$data instanceof $this->dataClass) { throw new FormException(sprintf('Form data should be instance of %s', $this->dataClass)); } $this->readObject($data); } }
/** * Initializes the field group with an object to operate on * * @see FieldInterface */ public function setData($data) { parent::setData($data); // get transformed data and pass its values to child fields $data = $this->getTransformedData(); if (!empty($data) && !is_array($data) && !is_object($data)) { throw new \InvalidArgumentException(sprintf('Expected argument of type object or array, %s given', gettype($data))); } if (!empty($data)) { $this->updateFromObject($data); } }
/** * Initializes the field group with an object to operate on * * @see FieldInterface */ public function setData($data) { parent::setData($data); // get transformed data and pass its values to child fields $data = $this->getTransformedData(); if (!empty($data) && !is_array($data) && !is_object($data)) { throw new \InvalidArgumentException(sprintf('Expected argument of type object or array, %s given', gettype($data))); } if (!empty($data)) { $iterator = new RecursiveFieldsWithPropertyPathIterator($this); $iterator = new \RecursiveIteratorIterator($iterator); foreach ($iterator as $field) { $field->updateFromObject($data); } } }