Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extending forms and rendering fields's label problem  #5564

Closed
@factorlabs

Description

@factorlabs

Hi,

First thank you for your greate work and amazing PHP framework.

I', starting use symfony with FOSUserBundle. For a moment I'm trying override default form of this Bundle. The problem is that the checkbox label is rendered twice...

My code:

namespace Factorlabs\Bundle\UserBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;

class RegistrationFormType extends BaseType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
           // other fields
            ->add('termsAccepted', 'checkbox', array('label' => 'Accept terms'))
        ;
    }

    public function getName()
    {
        return 'factorlabs_user_registration';
    }
}

The rendered HTML:

<div  id="fos_user_registration_form_termsAccepted_control_group" class=" control-group"><label for="fos_user_registration_form_termsAccepted" class=" required control-label">
    Accept terms
</label><div class=" controls" ><label class="checkbox"><input type="checkbox" id="fos_user_registration_form_termsAccepted" name="fos_user_registration_form[termsAccepted]" required="required"    class="" value="1"> 
Accept terms
</label></div></div>

I'm pretty sure that it is Symfony issue not the bundle problem.

Thanks for any suggestions!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions