Is it possible to build a form from 2 joined entity objects?
I have two entities property
& propertylanguage
which are joined on onetomany relation.
(One property can have many languages)
Language has a title
and description
colomns.
So one property can have a english, french, german title.
I am trying to build a form out of that. See below.
Controller: addProperty.php
class AddPropertyController extends Controller
{
// ....
public function indexAction(Request $request)
{
$property = new property;
$language = new propertyLanguage;
$property ->addpropertylanguage($language);
$form = $this->createForm(new propertyType($this->getDoctrine()),$property);
// .....
}
Form type: propertType.php
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('title', 'text');
// other ->add() below.
}
It returns the following error:
Neither property "title" nor method "getTitle()" nor method "isTitle()" exists in class "\defaultBundle\Entity\property"
Of course there is no property Title in property, but there is one in propertylanguage.. Even if I try: ->add('title', 'entity', array('class'=>defaultBundle:propertylanguage)); it doesn't work.
Thanks if you have time to help me.
Best,
Pierre.