src/FormHandler.php
public function bindEntity($entity, $fields = null, $validatable = true)
    {
        if ($this->submitted) {
            throw new BadMethodCallException("Entities cannot be assigned after FormHandler::handleRequest has been called");
        }

        $this->entities[] = array('entity' => $entity, 'fields' => $fields, 'validatable' => $validatable);

        if ($entity instanceof EntityInterface) {
            $entityData = $entity->getFormData(array_keys($this->fields), $fields);
        } else {
            $entityData = $this->entityProcessor->getFromEntity($entity, array_keys($this->fields), $fields);
        }

        $entityData = $this->transformToFormData($entityData);

        $this->data = array_replace_recursive($this->data, $entityData);
    }
public function bindEntity($entity, $fields = null, $validatable = true)
    {
        if ($this->submitted) {
            throw new BadMethodCallException("Entities cannot be assigned after FormHandler::handleRequest has been called");
        }

        $this->entities[] = array('entity' => $entity, 'fields' => $fields, 'validatable' => $validatable);

        if ($entity instanceof EntityInterface) {
            $entityData = $entity->getFormData(array_keys($this->fields), $fields);
        } else {
            $entityData = $this->entityProcessor->getFromEntity($entity, array_keys($this->fields), $fields);
        }

        $entityData = $this->transformToFormData($entityData);

        $this->data = array_replace_recursive($this->data, $entityData);
    }
public function bindEntity ( $ entity , $ fields = null , $ validatable = true ) { if ( $ this -> submitted ) { throw new BadMethodCallException ( "Entities cannot be assigned after FormHandler::handleRequest has been called" ) ; } $ this -> entities [ ] = array ( 'entity' => $ entity , 'fields' => $ fields , 'validatable' => $ validatable ) ; if ( $ entity instanceof EntityInterface ) { $ entityData = $ entity -> getFormData ( array_keys ( $ this -> fields ) , $ fields ) ; } else { $ entityData = $ this -> entityProcessor -> getFromEntity ( $ entity , array_keys ( $ this -> fields ) , $ fields ) ; } $ entityData = $ this -> transformToFormData ( $ entityData ) ; $ this -> data = array_replace_recursive ( $ this -> data , $ entityData ) ; }
Add an entity to the form. The entities values will be used to fill the form and the forms data
will be assigned to the entity when saveToEntities is called

@param $entity
@param null $fields
@param bool $validatable
@throws \Exception
Add an entity to the form . The entities values will be used to fill the form and the forms data will be assigned to the entity when saveToEntities is called