This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

How to Dynamically Generate Forms based on user Data

This forum is for non code-based questions, best practises, IDEs, version control tools, work opportunities, etc.

How to Dynamically Generate Forms based on user Data

by stoneisonline » Wed Aug 07, 2013 5:21 pm

I hope someone can help me:

I tried to do this but it doesn't work.

I always get the Error:
Fatal Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string in \vendor\symfony\symfony\src\Symfony\Component\Translation\IdentityTranslator.php line 62

in my form builder function

function(FormEvent $event) use($user, $factory){
$form = $event->getForm();

$formOptions = array(
'label' => "Standort",
'class' => 'igapSomaMitarbeiterdatenbankBundle:User',
'multiple' => false,
'expanded' => false,
'property' => 'standorte',
'query_builder' => function(EntityRepository $er) use ($user) {
return $er->createQueryBuilder('u')
->where(' = :owner')

// create the field, this is similar the $builder->add()
// field name, field type, data, options
$form->add($factory->createNamed('standorte', 'entity', null,$formOptions));

Standorte is a many to many connection to User.

so i hope there is an easy solution for this.
Junior Member
Posts: 2
Joined: Wed Aug 07, 2013 5:12 pm