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

Skip to content

Extending forms and rendering fields's label problem #5564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
factorlabs opened this issue Sep 20, 2012 · 4 comments
Closed

Extending forms and rendering fields's label problem #5564

factorlabs opened this issue Sep 20, 2012 · 4 comments

Comments

@factorlabs
Copy link

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!

@havvg
Copy link
Contributor

havvg commented Sep 20, 2012

This is an issue of MopaBootstrapBundle.

You can work around this by adding 'label_render' => false, to the field options.

@factorlabs
Copy link
Author

It works!
hvvg, thank you very much.

Is this issue reported already?

@fabpot
Copy link
Member

fabpot commented Sep 21, 2012

Closing as this issue is not related to Symfony.

@fabpot fabpot closed this as completed Sep 21, 2012
@PapyDanone
Copy link

I'm also having this issue with checkboxes and labels when using MopaBootstrapBundle. @factorlabs have you resolved the issue (without having to purely remove the labels) or has it been discussed with the guys at phiamo?

EDIT: found phiamo/MopaBootstrapBundle#369 Issue is still opened there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants