user2450639
user2450639

Reputation: 306

Symfony3 Form Error - A form with an empty name cannot have a parent form

My code was working fine, util this morning, I got error

[2018-08-17 12:39:42] request.INFO: Matched route "white_label_homepage". {"route":"white_label_homepage","route_parameters":{"_controller":"Bundle\\WhiteLabelBundle\\Controller\\DefaultController::indexAction","_route":"white_label_homepage"},"request_uri":"http://symfony/white-label","method":"GET"} []
[2018-08-17 12:39:42] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Form\Exception\LogicException: "A form with an empty name cannot have a parent form." at /home/symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 270 {"exception":"[object] (Symfony\\Component\\Form\\Exception\\LogicException(code: 0): A form with an empty name cannot have a parent form. at /home/symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php:270)"} []

I don't wanna past the all code, but there is no explanation for this error nowhere to be found on internet :). So if someone can please elaborate what is this error mean. In docs there is no setting a name for a form, and there is no parent, so what is this error all about?

Upvotes: 3

Views: 2730

Answers (1)

Michael Käfer
Michael Käfer

Reputation: 1806

Happens if you accidently pass an empty string to the form builder's add() method like in the following example:

$builder->add('');

Upvotes: 8

Related Questions