braincrafted/bootstrap-bundle — pull request #46 by egrajeda (2013-05-13 03:12:16+00:00)
Title: Nested forms uses <legend> to render its label

Hello,

I'm working on a project and we're starting to use your bundle to render fairly complex forms using Symfony2's FormBuilder with Bootstrap.

What this pull request makes is that it renders any nested form label using `
` instead of the usual `` that Symfony2 uses, I think it improves the visibility a lot and [Bootstrap seems to do it that way](http://twitter.github.io/bootstrap/base-css.html#forms).

You can create a basic form with nested forms with this code:
```
$formBuilder = $this->createFormBuilder(array());
$formBuilder->add(
$this->container->get('form.factory')->createNamedBuilder("section_1")
->add("name", "text", array("label" => "What is your name?"))
->add("number", "number", array("label" => "How old are you?"))
);
$formBuilder->add(
$this->container->get('form.factory')->createNamedBuilder("section_2")
->add("comments", "textarea", array("label" => "What are your comments about the site?"))
);

$form = $formBuilder->getForm();
```

And it will render something like this:

![screenshot from 2013-05-12 22 53 41](https://f.cloud.github.com/assets/12800/493962/5f552e3a-bb7a-11e2-8c69-ef1784a624b4.png)

When looking at the code you'll see that I had to implement a `TypeExtension`; that is because there was no easy way to differentiate when it was a form being rendered and when it was another type of question. Had to google a lot to find out that [one of the Symfony2 devs suggested to do it this way](https://github.com/symfony/symfony/issues/5060#issuecomment-7273707).

Thanks for the awesome bundle :).