Skip to content

[Form][Bug] Using radio elements results in an error when binding the request to the form. #2547

@Spea

Description

@Spea

When adding radio elements to the form and the requets is being bind to the form, the following error appears:

_Warning: array_replace_recursive(): Argument #1 is not an array in /.../vendor/symfony/src/Symfony/Component/Form/Form.php line 583_

Here is an example code:

<?php 
namespace My\Bundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

class TestController extends Controller
{
    public function testAction(Request $request)
    {
        $form = $this->createFormBuilder()
                ->add('test', 'text')
                ->add('test2', 'radio')
                ->add('test3', 'radio')
                ->getForm();

        if ($request->getMethod() == 'POST') {
            $form->bindRequest($request);
        }

        return $this->render('MyBundle:Test:form.html.twig', array(
            'form' => $form->createView(),
        ));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions