Easy integration of twitters bootstrap into symfony2

Overview

MopaBootstrapBundle

Build Status SensioLabsInsight Coverage Status

MopaBootstrapBundle is a collection of code to integrate twitter's bootstrap (http://twitter.github.com/bootstrap/) as easy as possible into your symfony (http://www.symfony.com) Project.

To use MopaBootstrapBundle and Twitter's Bootstrap 3 in your project add it via composer

Versions and dependencies

MopaBootstrapBundle Bootstrap Symfony PHP
[3.4] (master) ^3.0 ^4.4 || ^5.1 ^7.2 || ^8.0
[3.3] (3.3) ^3.0 ^2.3 || ^3.0 || ^4.0
[3.2] (unmaintained) ^3.0 ^2.3 || ^3.0
[3.1] (unmaintained) ^3.0 ^2.3 || ^3.0
[3.0] (unmaintained) ^3.0 ^2.3 || ^3.0
[2.3] (unmaintained) ^2.0 ^2.3
[2.2] (unmaintained) ^2.0 >=2.1,<2.4
[2.1] (unmaintained) ^2.0 ~2.1.0
[2.0] (unmaintained) ^2.0 ~2.0.0
[1.x] (unmaintained) ^1.0 ^2.0

Updates

New in 3.1: The way horizontal works has been slightly altered due to a change in Symfony forms. This may or may not affect some behavior of your existing forms. ALL root form elements, whether they have a parent form or not will start with horizontal === true (or whatever value you set in the config). For the most part this shouldn't affect many users.

horizontal will also correctly pass itself down to collection types (and all child forms). So if your collection is horizontal, so will the collection items. If you want your collection items only to be inline, then you can pass these options to your collection:

array(
    'entry_options' => array('horizontal' => false), //   2.8+
    'options' => array('horizontal' => false),       // < 2.8
)

horizontal_wrap_children has been removed, as this can be solved using the above options.

Branches

To use this bundle with bootstrap 3 use the latest release:

composer require mopa/bootstrap-bundle twbs/bootstrap

Or config via composer.json

For LESS:

{
    "require": {
        "mopa/bootstrap-bundle": "~3.0",
        "twbs/bootstrap": "~3.3.0"
    }
}

For SASS:

{
    "require": {
        "mopa/bootstrap-bundle": "~3.0",
        "twbs/bootstrap-sass": "~3.3.0"
    }
}

If you wish to use the current master branch, then use the following:

composer require mopa/bootstrap-bundle:dev-master twbs/bootstrap:dev-master

For bootstrap 2 use the v2.3.x branch:

composer require mopa/bootstrap-bundle:2.3.x-dev twbs/bootstrap:2.3.2

To understand which versions are currently required have a look into BRANCHES.md

Documentation

The bulk of the documentation is stored in the Resources/doc folder in this bundle In any case, if something is not working as expected after a update:

Live Show

To see the bundle, its capabilities and some more doc just have a look on

MopaBootstrapBundle Live

Additional Resources:

Installation

Installation instructions are located in the

Included Features

  • Bootstrap Version detection via Composer Bridge
  • Twig Extensions and templates for use with symfony2 Form component
    • control your form either via the form builder or the template engine
    • control nearly every bootstrap2 form feature
    • javascript and twig blocks for dynamic collections
  • A generic Navbar class to generate your Navbar outside the template
    • helpers for dropdowns, seperators, etc.
  • A generic Tab class to Manage bootstrap tabbing
  • Twig templates for KnpPaginatorBundle (https://github.com/knplabs/KnpPaginatorBundle)
  • Twig templates for CraueFormFlowBundle (https://github.com/craue/CraueFormFlowBundle)
  • Twig template for KnpMenuBundle (https://github.com/KnpLabs/KnpMenuBundle)
    • icon support on menu links

Translations

If you use KnpPaginatorBundle with MopaBootstrapBundle, you can translate labels to your language. To do this add new file

Resources/translations/pagination.[YOUR LOCALE CODE].yml

As example you have there Polish translation.

Versioning

We aim to follow semantic versioning with our releases.

Contribute

If you want to contribute your code to MopaBootstrapBundle please be sure that your PR's are valid to Symfony2.1 Coding Standards. You can automatically fix your code for that with PHP-CS-Fixer tool.

You can see who already contributed to this project on Contributors page

License

This bundle is under the MIT license. For more information, see the complete LICENSE file in the bundle.

Comments
  • Linking glyphicons-halflings to Resources/public/img

    Linking glyphicons-halflings to Resources/public/img

    Is it possible to add to your linking function a link for the glyphicons-halflings images to mopabootstrapbundle/Resources/public/img ? This would help a lot and so we don't have to copy the icon file becouse we can use it right from that place.

    solution available 
    opened by fkrauthan 31
  • Finishing 3.0

    Finishing 3.0

    | Issue | Status | Assigned | Commit | | --- | --- | --- | --- | | Make all files PSR-2 compatible | Complete | @sstok | a370328 | | Update Form Collections Docs | Complete | @phiamo | f206207 | | Clean views/base_initializr.html.twig | Complete | @mweimerskirch | 25bcbed | | Twig\MenuExtension creates a MenuConverter every time | Complete | @isometriks | 9c84983 | | bootstrap-collection.js License | Not Completed | (none) | (none) | | Fix navbar-right issue | Completed | @isometriks | (none) | | Replace glyphs with icon() | Completed | @isometriks | (none) |

    opened by isometriks 30
  • label render

    label render

    Resources/views/Form/fields.html.twig line 509

    and not label_render %}

    if not render - render empty? empty colum for collection

    {% if horizontal and not label_render %}
        <label class="{{ horizontal_label_class }} control-label"></label>
    {% endif %}
    {% if horizontal %}
        <div class="{{ horizontal_input_wrapper_class }}">
    {% endif %}
    

    maybe

    {% if horizontal %}
        {% if label_render %}
        <label class="{{ horizontal_label_class }} control-label"></label>
        <div class="{{ horizontal_input_wrapper_class }}">
        {% else %}
        <div>
        {% endif %}
    {% endif %}
    
    opened by ivan1986 27
  • Error blocks

    Error blocks

    For some reason my errors are being displayed with a different class and looks a bit ugly now. Is there a way to restore them to the original classes easily?

    <div class="alert alert-error fade in  alert-block">
                    This value should not be blank.
            </div>
    

    screen shot 2013-06-06 at 5 45 24 pm

    important 
    opened by trsteel88 27
  • Form Widget Translations

    Form Widget Translations

    Form widget labels from FOSUserBundle, eg:

    {{ form_widget(form) }}
    

    no longer translate when activating MopaBootstrapBundle:Form:fields.html.twig for the whole project. MopaBootstrapBundle:Form:fields.html.twig doesn't seem to know how to translate them.

    opened by nurikabe 27
  • icons not displayed - bootstrap 3.3+ sass version

    icons not displayed - bootstrap 3.3+ sass version

    Hi,

    I'm a "fresh" (few months) newbie with symfony and I tried to setup this bundle: everything seems to work but can't make the glyphicons work (been on it for 24h).

    • Followed all instructions to use this bundle with bootstrap (3.3+) sass version (using compass as parser), resulting in:

    config.yml

    assetic:
        debug:          "%kernel.debug%"
        use_controller: false
    #     bundles: []
    #     java: /usr/bin/java
        filters:
            cssrewrite: ~
            compass:
                bin: /usr/local/bin/compass
            yui_css:
                jar: %kernel.root_dir%/Resources/java/yuicompressor.jar
            yui_js:
                jar: %kernel.root_dir%/Resources/java/yuicompressor.jar
    mopa_bootstrap:
        icons:
            icon_set: glyphicons
            shortcut: icon
    

    layout.html.twig

    {% extends 'MopaBootstrapBundle::base_sass_3.2.html.twig' %}
    
    {% block head_style %}
        {% stylesheets
            filter='compass, cssrewrite, ?yui_css' 
            'bundles/mopabootstrap/sass/mopabootstrapbundle-3.2.scss'
            'bundles/axcore/css/AXCoreLayout.scss'
        %}
            <link rel="stylesheet" href="{{ asset_url }}" type="text/css" media="screen" />
        {% endstylesheets %}
    {% endblock head_style %}
    
    {% block head_script %}
        {% javascripts
            filter='?yui_js'
            '@AXCoreBundle/Resources/public/jquery/jquery-1.11.3.min.js'
        %}
            <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
    {% endblock head_script %}
    
    {% block foot_script_assetic %}
        {% javascripts 
            filter='?yui_js'
            '@MopaBootstrapBundle/Resources/public/bootstrap-sass/assets/javascripts/bootstrap/tooltip.js'
            '@MopaBootstrapBundle/Resources/public/bootstrap-sass/assets/javascripts/bootstrap/*.js'
            '@MopaBootstrapBundle/Resources/public/js/mopabootstrap-collection.js'
            '@MopaBootstrapBundle/Resources/public/js/mopabootstrap-subnav.js'
            '@AXCoreBundle/Resources/public/js/*'
        %}
            <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
    {% endblock foot_script_assetic %}
    // some other stuff
    
    • But can't get the resource:

    The requested URL /bundles/mopabootstrap/fonts/bootstrap/glyphicons-halflings-regular.woff2 was not found on this server.

    Similar messages for woff and ttf.

    Maybe I'm desperately blind or tired but would much appreciate support on this. Thanks!

    opened by ArnaudCode 23
  • form and twig template for subforms

    form and twig template for subforms

    block for subforms is {%block form_row%} right ? It put subform in a separate

    with class

    
    div class="{{ horizontal_input_wrapper_class }}"
    

    in my config.yml (mopa settings) horizontal_input_wrapper_class = 'col-lg-9'

    below the result ....

    mopa_twig_issue

    opened by paskuale75 23
  • [WIP] add 2 more navigation bars

    [WIP] add 2 more navigation bars

    To open discussion on this topic I've rebased my branch to current master and make this PR. This is not merge ready ATM. Today I'll try to make refactoring to use one renderer to render all 3 types of bars I'll want to make support for.

    Q1: navbar naming? my proposition is to name them as:

    • topNavbar - f.ex. fixed top one with branding field (current one)
    • mainNavbar - current one but without branding field
    • subNavbar - new one which snap to topNavbar or top of page when user scrolls page

    this will be not BC but will let us make it clear what will render which bar

    feature 
    opened by nysander 23
  • Choose specific fields to display from a form collection

    Choose specific fields to display from a form collection

    Is there a way that helps me display specific fields from a collection in my form type? It would be most helpful if it can be done through the twig. If my question is not clear, I'll provide you an example. Thanks for your help. And keep up the good work guys :)

    opened by NightFox7 21
  • Error on get glyphicons-halflings [ Issue not repeated ]

    Error on get glyphicons-halflings [ Issue not repeated ]

    I have a Symfony 2.0x installation and MopaBootstrapBundle.

    In my error log, i can see: request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /bundles/MopaBootstrap/img/glyphicons-halflings-white.png" (uncaught exception).

    Of course, i cant use icons related classes. The issue are that the generated route for the file has a CamelCase Bundle name ( MopaBootstrap ). My bootstrap is in the bundle folder ( /vendor/bundles/Mop/BootstrapBundle/Resources/bootstrap). At '/web/bundles' dir, i have a folder called 'mopabootstrap' and not 'MopaBootstrap'. Obviously in unix systems this fails.

    What can i do? It is an issue?

    I read https://github.com/phiamo/MopaBootstrapBundle/issues/81 and the additional info doc but continues with the same.

    Thanks a lot!

    opened by smoya 21
  • labels not available for all fields

    labels not available for all fields

    I've been adding custom labels in my Type class for some fields, including two datetime fields, but the labels don't show up. Looking at the fields.html.twig, I noticed the labels are indeed not added in the widget blocks for several fields.

    Now, before I create a pullrequest to fix this, I was wondering if there was a specific reason for doing this? Perhaps I'm missing something here, so I want to make sure I don't do useless work ;)

    opened by skoop 20
  • Does

    Does "widget_addon_prepend" work with Symfony 4?

    I'm running Symfony 4 and installed MopaBootstrapBundle with composer: "composer require mopa/bootstrap-bundle", but the "widget_addon_prepend" on my forms do not work.

    I get the following error: "The option "widget_addon_prepend" does not exist."

    Besides installing the bundle with composer, I have not done anything else, is there anything I need to do to get it work? Is it Symfony 4 compatible?

    Below are screenshots showing MopaBootstrapBundle has been added to my "bundles.php" as well as my form element showing the usage of "widget_addon_prepend".

    Thank you for any help!!

    This is what I'm trying to achieve:

    Screenshot 2019-07-16 at 18 49 41 Screenshot 2019-07-16 at 18 45 23 Screenshot 2019-07-16 at 18 44 31
    opened by vanniekerkalex 5
  • Error when using the most recent 1.* Twig version (1.42.0, session_flash issue)

    Error when using the most recent 1.* Twig version (1.42.0, session_flash issue)

    The current bundle (version 3.3.0) uses session_flash and something has changed in the most recent version twig/twig (1.42.0) that raises an error.

    Workaround: Forcing my site's composer.json to explicitely use twig/twig 1.41.0 temporary solves it.

    opened by DaniFuchoBasetis 1
  • new line inserted at start for every response when MopaBootstrapBundle included with Symfony 4

    new line inserted at start for every response when MopaBootstrapBundle included with Symfony 4

    It took me a while to track down the source of this issue, but I was getting a new blank line at the start of every response returned, even debug error pages and JSON responses. I narrowed it down to including the MopaBootstrapBundle. I am using Symfony 4.1. If I edit the file Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle and comment out the line

    use Symfony\Component\HttpKernel\Bundle\Bundle;

    and remove extends Bundle then the blank line disappears. However, this is the only bundle this affects, so I'm not sure where the actual error is happening. At the moment this bundle is unusable with Symfony 4.

    opened by PaddyLock 0
  • Sections in forms

    Sections in forms

    Hi is it possible to setup sections in forms (other than tabs)? I didn't see any option in the doc. One solution would be to assign a specific call to the first field of a section but I don't know how to assign it to the form-group div rather than to the input itself. Ideas are welcome. Thanks!

    opened by vialcollet 1
  • Add embed form id in parent div

    Add embed form id in parent div

    When using an embed form, currently it displays like this :

    <div class="form-group">
        <div id="my_form_foo" class="form-group">...</div>
        <div id="my_form_bar" class="form-group">...</div>
    </div>
    

    This PR adds the form id to the top level div, selecting it is now easier :

    <div id="my_form" class="form-group">
        <div id="my_form_foo" class="form-group">...</div>
        <div id="my_form_bar" class="form-group">...</div>
    </div>
    
    opened by EmmanuelVella 0
Releases(v3.4.2)
Yii 2 Bootstrap 5 Extension

Twitter Bootstrap 5 Extension for Yii 2 This is the Twitter Bootstrap extension for Yii framework 2.0. It encapsulates Bootstrap 5 components and plug

Yii Software 48 Dec 14, 2022
yii2-app-advanced with Twitter Bootstrap 5

Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.

Nedarta 1 Nov 5, 2021
The package contains a bootstrap for running Yii3 web application.

Yii Web Runner The package contains a bootstrap for running Yii3 web application. Requirements PHP 8.0 or higher. Installation The package could be in

Yii Software 4 Oct 15, 2022
Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker

Yii2 Date/Time Picker Widget Date/Time Picker widget for Yii2 framework Based on Eonasdan's Bootstrap 3 Date/Time Picker Demo Since this is a part of

Yevhen Terentiev 8 Mar 14, 2022
A collapsible side navigation menu built to seamlessly work with Bootstrap framework

yii2-widget-sidenav This widget is a collapsible side navigation menu built to seamlessly work with Bootstrap framework. It is built over Bootstrap st

Kartik Visweswaran 36 Apr 9, 2022
An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

yii2-widget-fileinput The FileInput widget is a customized file input widget based on Krajee's Bootstrap FileInput JQuery Plugin. The widget enhances

Kartik Visweswaran 227 Nov 6, 2022
An extended bootstrap alert and alert block widget for Yii2 (sub repo split from yii2-widgets)

yii2-widget-alert This extension contains a couple of useful widgets. The Alert widget extends the \yii\bootstrap\Alert widget with more easy styling

Kartik Visweswaran 28 Mar 12, 2022
This JSON marshaller is based on the one built into FEAST framework

Standalone JSON marshaller based off the one built into FEAST framework at feast/framework on packagist or feastframework/framework on github

null 13 Dec 9, 2022
Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

Yii2 SwitchInput widget turns checkboxes and radio buttons into toggle switchinputes

Kartik Visweswaran 38 Sep 21, 2022
Plates Template Integration for Slim micro framework 3

Plates Template Integration for Slim micro framework 3 Render your Slim 3 application views using Plates template engine. Install Via Composer $ compo

Projek XYZ 26 Feb 5, 2022
🎲 This project provides an integration for the Doctrine ORM and the Hyperf framework

Hyperf ?? Doctrine This project provides an integration for the Doctrine ORM and the Hyperf framework. Install composer require leocavalcante/hyperf-d

Leo Cavalcante 49 Dec 3, 2022
This extension provides Flysystem integration for the Yii framework

This extension provides Flysystem integration for the Yii framework. Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.

Alexander Kochetov 276 Dec 9, 2022
Integration testing helpers for the Slim Framework

Slim Test Helpers Integration testing helpers for the Slim Framework 3 For a full example, please see the companion repo at there4/slim-unit-testing-e

There4 60 Oct 26, 2022
Fast and easy PHP framework

Español | English Fácil, rápido y en español (Or should I say fast and easy?) Bienvenidos a KumbiaPHP Framework Versión 1 Manual en construcción de la

KumbiaPHP Framework 281 Jan 2, 2023
🐘🎓📝 PHP Library providing an easy way to spellcheck multiple sources of text by many spellcheckers

PHP-Spellchecker Check misspellings from any text source with the most popular PHP spellchecker. About PHP-Spellchecker is a spellchecker abstraction

Philippe SEGATORI 257 Jan 2, 2023
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
A very slight PHP framework, very easy to use and integrate.

A very slight PHP framework, very easy to use and integrate.

Jerry 95 Oct 26, 2022
Lite & fast micro PHP abuse library that is **easy to use**.

Utopia Abuse Utopia framework abuse library is simple and lite library for managing application usage limits. This library is aiming to be as simple a

utopia 23 Dec 17, 2022
PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.

?? tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.

tknet 656 Jan 4, 2023