Symfony 2 - Polimorfismo

Considere la siguiente situación:

Clase de prueba:

class Test{
    protected $title;
    protected $description;
}

Base Question class:

class BaseQuestion{
    protected $Test
    protected $question;
}

Text Question class:

class TextQuestion extends BaseQuestion{
}

Checkbox Question class:

class CheckboxQuestion extends BaseQuestion{
    protected $options;
}

So I have all this setup, now I need an easy way for people to create new tests with questions.

I first started by using Sonata Admin as a CMS, which was working fine as long as I didn't use polymorphism and just used 1 type of question. Using the inline option you could create questions when you were creating test. However including the inheritance to Sonata Admin with their inline option proved to be unsuccessful.

I then tried to remove all the Sonata Admin stuff and just build a plain form to do this but again, with only 1 type of question this works very well with embedded forms. But as soon as I tried implementing it with the inheritance classes, things proved more difficult.

Intenté usar el Infinite PolyCollection Bundle but couldn't find anything on how to display the form. I then found the Arse Polycollection bundle (which uses the Infinite bundle) but can't get it to work even though I was following the tutorial step by step.

Currently it's giving me the following error:

FatalErrorException: Error: Call to undefined method Symfony\Component\Form\FormBuilder::getTypes()

I am getting clueless on how to proceed with this, has anyone got the above bundles working before? Or do you have other suggestions on how to set up a (small) CMS system for this?

Update: I basically did everything manual now and it's working but I do hope they include a way of doing this with the framework in the future.

preguntado el 28 de mayo de 14 a las 12:05

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.