Category : formbuilder

When building a form in symfony form builder changing the choice attribute can be done. However, for the label attribute this doesn’t seem possible. Here is how i modify the choice: $builder->add(‘type’, EntityType::class, [ ‘class’ => Resourcetype::class, ‘multiple’ => true, ‘expanded’ => true, ‘choice_attr’ => function (?Resourcetype $type) { return [‘class’ => $type->getSafeName() . ‘-parent ..

Read more

I created a Symfony Poll-Bundle which has the Entitys Campaign->Block->Line->Field->PollResult. So i have a CollectionType CampaignType which consists of many blocks. Block is also a CollectionType and consists of many Lines. One Line consist of many Fields and every Field has one PollResult which holds the Answer of the user who filled out the campaign. ..

Read more

I’m trying to add a repeated password field to a signup form but the value returns an array of the two field values instead of combining the values to a string. This code return a string: ->add(‘plainPassword’, PasswordType::class) But this one returns an array: ->add(‘plainPassword’, RepeatedType::class, [ ‘type’ => PasswordType::class, ‘invalid_message’ => ‘Passwords must match.’, ..

Read more

In my formbuilder I am using querybuilder to get the firstname: $options[‘class’] = ‘AppEntityData’; $options[‘choice_label’] = ‘content’; $firstname = "81"; $options[‘query_builder’] = function (EntityRepository $er) use ($firstname) { return $er->createQueryBuilder(‘data’) ->andWhere(‘data.fields = :field’) ->setParameter(‘field’, $firstname) ; } The output is Fred Alternatively I can also get the company: $lastname = "35"; $options[‘query_builder’] = function (EntityRepository ..

Read more