Question: I have an xml schema - 

```
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns="http://www.tibco.com/schemas/RegTestingStub/SharedResources/SchemaDefinitions/CommonXSD/Schema.xsd2"
     targetNamespace="http://www.tibco.com/schemas/RegTestingStub/SharedResources/SchemaDefinitions/CommonXSD/Schema.xsd2"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">
    <xs:element name="AccumulateResponse" type="AccumulateResponse"/>
    <xs:complexType name="AccumulateResponse">
        <xs:sequence>
            <xs:element name="TestCase" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="Transactionid" type="xs:string"/>
                        <xs:element name="TransactionType" type="xs:string"/>
                        <xs:element name="Status" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

```

I am doing this conversion i the following steps - 
1) Generate Java Classes from XML Schema using XJC
2) Compile the classes using Java Compiler API
3) unmarshalling the class instance by JAXB

But they are all heavy IO operations. Is there a way to do it in memory?

Answer: 
To avoid `patologies` in select field override the widget for the field

```
{% block pathologie_widget %}
    <b>{{ value }}</b>
{% endblock %}

```

See <http://symfony.com/doc/current/book/forms.html#form-theming> for details about for theming

Or depending on how you are rendering your collection you can also take this way:
[Symfony2 formbuilder - entity readonly field as label](https://stackoverflow.com/questions/24950601/symfony2-formbuilder-entity-readonly-field-as-label/24953112#24953112)

To have all pathologies connected to a new user just add them in the `__construct` of `User`

```
public function __construct() {

   // get all phatologies

   foreach ($allPhatologies as UserPathologie) {
       $this->userPathologies->add(new UserPathologie());
   }

}

```
This is how I did to get it work

First add `cascade={"persist"}` to the OneToMany relation in User to persist automatically the user pathologies

```
Class User
{
    /**
     * @ORM\OneToMany(targetEntity="Myapp\UserBundle\Entity\UserPathologie", mappedBy="user", cascade={"persist"})
     */ 
    protected $userPathologies;
}

```

Then, add all pathologies to the new entity as @Hpatoio suggested

```
private function createRegisterForm(User $entity)
{
    $em = $this->getDoctrine()->getManager();
    $pathologies =  $em->getRepository("MyappUserBundle:Pathologie")->findAll();

    //Loop all pathologies
    foreach($pathologies as $patho) {
        $up = new UserPathologie();
        $up->setPathologie($patho);
        $up->setUser($entity);
        $up->setAtteint(false);

        //Add each pathologie to the User entity
        $entity->getUserPathologies()->add($up);
    }

    $form = $this->createForm(new UserRegisterType(), $entity, array(
        'action' => $this->generateUrl('register_user'),
        'method' => 'POST',
    ));

    return $form;
}

```

And in the twig template, I used again a loop to get the expected result

```
{% for up in form.userPathologies%}
    <input type="hidden" name="{{ up.pathologie.vars.full_name }}" id="{{ up.pathologie.vars.id }}" value="{{ up.pathologie.vars.value }}" />
    <p class="line"><label>{{ up.vars.value.pathologie }}</label>{{ form_widget(up.atteint) }}</p>
    <p class="line">{{ form_row(up.cause) }}</p>
{% endfor %}

```