Reputation: 15432
I have a simple form:
class SignInType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('_username', 'text');
$builder->add('_password', 'password');
$builder->add('Sign in', 'submit');
}
public function getName()
{
return 'sign_in';
}
}
which I call in my 'sign-in' action:
public function signInAction()
{
$form = $this->createForm(new SignInType(), null,
[ 'action' => $this->generateUrl('my_project_account_sign_in_process') ]
);
However binding the POST request results in an invalid form, with an error of This form should not contain extra fields
. It seems to be the submit button that's causing the issue - how can I resolve this?
public function signInProcessAction(Request $request)
{
$doctrineManager = $this->getDoctrine()->getManager();
$form = $this->createForm(new SignInType());
$form->handleRequest($request);
...
Upvotes: 0
Views: 175
Reputation: 15432
I've fixed this by removing the space from my button's name:
public function buildForm(FormBuilderInterface $builder, array $options)
{
...
$builder->add('Sign_in', 'submit');
}
Upvotes: 1
Reputation: 367
Then the error This form should not contain extra fields
is surely caused by the form which have no name. Symfony can't get form fields and try to get some random other element ?
Upvotes: 0