{% 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 #}
{{ form_widget(form.startAt) }} - {{ form_widget(form.endAt) }}
{{ form_widget(form.special) }} {{ form_rest(form) }}
{% endblock %} {% block date_widget %} {% if widget == 'single_text' %} {{ block('field_widget') }} {% else %} {% set attr = attr|merge({'class': attr.class|default('')}) %} {{ date_pattern|replace({ '{{ year }}': form_widget(form.year, {'attr': {'class': attr.widget_class|default('') ~ ' input-mini'}}), '{{ month }}': form_widget(form.month, {'attr': {'class': attr.widget_class|default('') ~ ' input-small'}}), '{{ day }}': form_widget(form.day, {'attr': {'class': attr.widget_class|default('') ~ ' input-mini'}}), })|raw }} {{ block('help') }} {% endif %} {% endblock date_widget %} {% block headline %}Collection Forms{% endblock headline %} {% block content %}
{{ form_widget(form) }}

Button Icons

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!

Easy use of collections

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 %}
{% endblock content %} {% set showTemplate = _self %}{% set showForm = formType %}