Form/EventListener/CharacteristicsResizeListener.php
public function preSetData(FormEvent $event)
    {
        $form = $event->getForm();
        $data = $event->getData();

        if (null === $data) {
            throw new \InvalidArgumentException('Can\'t handle null datas.');
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }

        foreach ($form as $name => $child) {
            $form->remove($name);
        }

        foreach ($this->schema->getGroups() as $schemaGroup) {
            $form->add($schemaGroup->getName(), new GroupType(), array('label' => $schemaGroup->getTitle()));
            $groupForm = $form->get($schemaGroup->getName());
            foreach ($schemaGroup->getDefinitions() as $schemaDefinition) {
                if (true === $schemaDefinition->getVirtual()) {
                    continue;
                }
                $this->appendProperForm($groupForm, $schemaDefinition);
                $this->appendProperData($data, $schemaDefinition);
            }
        }

        $event->setData($data);
    }
public function preSetData(FormEvent $event)
    {
        $form = $event->getForm();
        $data = $event->getData();

        if (null === $data) {
            throw new \InvalidArgumentException('Can\'t handle null datas.');
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }

        foreach ($form as $name => $child) {
            $form->remove($name);
        }

        foreach ($this->schema->getGroups() as $schemaGroup) {
            $form->add($schemaGroup->getName(), new GroupType(), array('label' => $schemaGroup->getTitle()));
            $groupForm = $form->get($schemaGroup->getName());
            foreach ($schemaGroup->getDefinitions() as $schemaDefinition) {
                if (true === $schemaDefinition->getVirtual()) {
                    continue;
                }
                $this->appendProperForm($groupForm, $schemaDefinition);
                $this->appendProperData($data, $schemaDefinition);
            }
        }

        $event->setData($data);
    }
public function preSetData ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; $ data = $ event -> getData ( ) ; if ( null === $ data ) { throw new \ InvalidArgumentException ( 'Can\'t handle null datas.' ) ; } if ( ! is_array ( $ data ) && ! ( $ data instanceof \ Traversable && $ data instanceof \ ArrayAccess ) ) { throw new UnexpectedTypeException ( $ data , 'array or (\Traversable and \ArrayAccess)' ) ; } foreach ( $ form as $ name => $ child ) { $ form -> remove ( $ name ) ; } foreach ( $ this -> schema -> getGroups ( ) as $ schemaGroup ) { $ form -> add ( $ schemaGroup -> getName ( ) , new GroupType ( ) , array ( 'label' => $ schemaGroup -> getTitle ( ) ) ) ; $ groupForm = $ form -> get ( $ schemaGroup -> getName ( ) ) ; foreach ( $ schemaGroup -> getDefinitions ( ) as $ schemaDefinition ) { if ( true === $ schemaDefinition -> getVirtual ( ) ) { continue ; } $ this -> appendProperForm ( $ groupForm , $ schemaDefinition ) ; $ this -> appendProperData ( $ data , $ schemaDefinition ) ; } } $ event -> setData ( $ data ) ; }
Pre set data event handler.

@param \Symfony\Component\Form\FormEvent $event
@throws \Symfony\Component\Form\Exception\UnexpectedTypeException
@throws \InvalidArgumentException
Pre set data event handler .