Category : forms

I’m using Symfony EntitType to display a list of options from my database. The bit of code is this : use SymfonyBridgeDoctrineFormTypeEntityType; … ->add( ‘defaultProduct’, EntityType::class, array( ‘class’ => ‘AppEntityProductProduct’, ‘label’ => ‘Product’, ’empty_data’ => null, ‘required’ => false, ‘choice_label’ => ‘name’, ‘help’ => "The product", ) ) This works fine and displays an option ..

Read more

If i clique on submit bottom, I got this error : Could not parse property path "children[upcomingTours].children[[0]].children[address].children[street].data". Unexpected token "]" at position 36. This is the hierarchy of my form – TourType (custom form) – UcomingTour (CollectionType) – AddressType (custom form) HTLM <div> <label for="tour_upcomingTours_0_address_street">Adresse</label> <input type="text" id="tour_upcomingTours_0_address_street" name="tour[upcomingTours][0][address][street]" placeholder="Tapez un nom de rue"> </div> ..

Read more

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 am having trouble submitting two forms. I have two form types: class ApplicationErrorType extends AbstractErrorType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(’email’, TextType::class, [ ‘label’ => ‘Notification email*’, ‘required’ => true ]) ->add(‘problemName’, TextType::class, [ ‘label’ => ‘The name of the ..

Read more