braincrafted/bootstrap-bundle — pull request #290 by derpue (2014-08-14 16:30:30+00:00)
Title: Use Bootstrap static control from inside form

Convenience stuff to define BS static form controls inside the forms creation.

This could of course all be done with fiddling in the template, rendering the form row-wise and using the twig `form_control_static()` function, but i'm often in the need to display one or more fields from my entity as static controls, and this let me do a simple `{{ form(form, {'style': 'horizontal'}) }}` in the template.

This patch consists of two commits which are independent from each other, just provide different ways and usages:

### Extension
Provides for all fields which are rendered as `form_widget_simple`(date, time, datetime with `'widget' => 'single_text'` set, number, integer, url, email) to be rendered as static control, using :

```php
// simple field:
$builder->add('fieldname', 'number', array('static_control' => true));

// datetimefield with formatting:
$builder->add('updatedAt', 'datetime', array(
'widget'=>'single_text',
'static_control'=>true,
'format' => 'dd.MM.yyyy HH:mm:ss',
));

```
You should always set the field type explicitly instead of using autoguessing, which leads sometimes to extra attributes in the markup (eg `maxlength`) that break html validation.

### Static control field type
Just another way to get a 'static control' rendered in the form:

```php
// with a fields value (should be convertable to string):
$builder->add('fieldname', 'bs_static', $optionsIdNeeded);

// really static content
$builder->add('somenamenotafield', 'bs_static', array('mapped' => false, 'data'=> 'YourContentHere'));

// fields as datetime which need a Transformer (note the two `$builder->` calls):
$builder->add(
$builder->create('updatedAt', 'bs_static', $optionsIdNeeded)
->addViewTransformer(new DateTimeToStringTransformer(null, null, 'd.m.Y H:m:s'))
);
```

I'm not sure which one is the best to use, as both have advantages.

And sorry for not providing tests, i still need to learn/understand that mockup stuff