Symfony\Component\Form\FieldGroup::setData PHP Method

setData() public method

Initializes the field group with an object to operate on
See also: FieldInterface
public setData ( $data )
    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);
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function setData($data)
 {
     if ($this->mode === self::GROUP) {
         parent::setData($data);
     } else {
         Field::setData($data);
     }
 }
All Usage Examples Of Symfony\Component\Form\FieldGroup::setData