{% extends "MopaBootstrapSandboxBundle::layout.html.twig" %} {% from 'MopaBootstrapBundle::flash.html.twig' import session_flash %} {% form_theme form _self %} {% block example_date_widget %} {# block to create the example_date_widget from ExamleDateType #}
To make use of the button icons you can either apply them in the FormType:
$builder
->add('nice_email_collection','collection', array(
'widget_add_btn' => array(
'icon' => 'plus-sign',
'label' => 'add email'
),
))
;
Or configure them globally:
mopa_bootstrap:
form:
collection:
widget_remove_btn:
icon: trash
icon_color: white
widget_add_btn:
icon: plus-sign
And if configured globally you can override them again in the FormType!
We often saw probs when using collection, so we added some code to ease the use
Please review your javascript includes, we provide a new mopabotstrap-collection.js
Include it in your layout, or per page, as you like.
For an easy collection with e.g. just a bunch of mail adresses just add the collection to your form
An example: to generate nice inputs with icons you dont write one line of html:
$builder
->add('nice_email_collection','collection', array(
'type' => 'email',
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'widget_add_btn' => array('label' => 'add email', 'attr' => array('class' => 'btn btn-primary')),
'options' => array( // options for collection fields
'widget_remove_btn' => array('label' => 'remove', 'attr' => array('class' => 'btn btn-primary')),
'attr' => array('class' => 'span3'),
'widget_addon' => array(
'type' => 'prepend',
'text' => '@',
),
'widget_control_group' => false,
)
))
;
And in your markup you just need one line:
{% raw %}
<form class="form-horizontal">
{{ form_widget(form) }}
</form>
{% endraw %}