Category: symfony-forms

Symfony2: How can I mock a custom constraint with DI in unit test FormType?

I’m writing unit test for Symfony FormType. By following the article https://symfony.com/doc/2.8/form/unit_testing.html, everything worked very smoothly until I added a custom constraint and that constraint’s Validator had a constructor with an argument, then an error was thrown as below: [ArgumentCountError]…

Could not determine access type for property "offerOrders" in class "AppFormOrderType": Neither the property

the error is: Could not determine access type for property "offerOrders" in class "AppFormOrderType": Neither the property "offerOrders" nor one of the methods "addOfferOrder()"/"removeOfferOrder()", "setOfferOrders()", "offerOrders()", "__set()" or "__call()" exist and have public access in class "AppFormOrderType".. PhotoSession Class <?php…

How to access submitted data inside FormType class?

How to access submitted data inside FormType class in Symfony 4/5? Assuming that form is not mapped with any Entity and its submit back to same controller / action. // srcFormSomeFormType.php —————————————————– … public function buildForm(FormBuilderInterface $builder, array $options) {…

Hide a label from an Embedded Form Type in a Collection type

I have a form collection type called ContactType which has a CollectionType field called contact2Companies with entry_type AddCompanyFromContactType. AddCompanyFromContactType has a field company which uses another form type CompanyNameType. In the frontend, we see the label Unternehmen from ContactType. In…