Developed with love by KnpLabs Hire us for your project!
26

ElnurBootstrapBundle

by elnur

Unobtrusive support for Bootstrap 3

ElnurBootstrapBundle

This bundle provides unobtrusive support for Bootstrap 3. By “unobtrusive” I mean that it doesn't force some particular
styling unless you explicitly tell it to. For example, by default, forms get the default Bootstrap layout — not
horizontal or something else like that.

Installation

The bundle assumes that you install Bootstrap yourself by whatever means you like — be it a Composer package or via
Bower.

To install the bundle itself, add the following to your composer.json:

{
    "require": {
        "elnur/bootstrap-bundle": "~0.1"
    }
}

And tell Composer to install the bundle:

$ php composer.phar update elnur/bootstrap-bundle

Then enable the bundle by adding the following to your AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        // ...
        new Elnur\Bundle\BootstrapBundle\ElnurBootstrapBundle,
    );

    // ...
}

Forms

To render a form with the default Bootstrap layout, just do the following:

{{ form(form) }}

If you want to use another layout — say, horizontal — tell about that explicitly:

{{ form(form, {layout: 'horizontal'}) }}

Supported layouts are:

  • default,
  • horizontal,
  • inline, and
  • navbar.

Buttons

Context

To set a button's context, use the context option:

$builder->add('submit', 'submit', array(
    'context' => 'primary',
));

Bootstrap ships with the following contexts:

  • default,
  • primary,
  • success,
  • info,
  • warning,
  • danger, and
  • link.

Input groups

To prepend or append textual addons to an input, use the prepend and append options, respectively:

$builder->add('price', 'integer', array(
    'prepend' => '$',
    'append' => '.00',
));

Converting Labels to Placeholders

If you want to convert labels to placeholders, set the labels_to_placeholders option to true:

{{ form(form, {labels_to_placeholders: true}) }}

Flash Messages

To render flash messages just add the following to your layout template:

{% include 'ElnurBootstrapBundle::flash.html.twig' %}
Copyright (c) 2013-2014 Elnur Abdurrakhimov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • use psr-4 autoloader
    By jrobeson, 4 years ago
  • Fix checkbox label class name
    By redstar504, 5 years ago
  • Show errors on checkbox fields
    By redstar504, 5 years ago
  • Display checkbox label as string
    By redstar504, 5 years ago
  • Add the license to the remaining PHP files
    By elnur, 5 years ago
  • Update the copyright year range
    By elnur, 5 years ago
  • Bump the branch alias
    By elnur, 5 years ago
  • Update the version to use in the installation instructions
    By elnur, 5 years ago
  • Add a section on converting labels to placeholders to the README
    By elnur, 5 years ago
  • Add a section on input groups to the README
    By elnur, 5 years ago
  • Make form type extension classes overridable using parameters
    By elnur, 5 years ago
  • Add a section on buttons context to the README
    By elnur, 5 years ago
  • Add missing dependencies
    By elnur, 5 years ago
  • Inherit PHPDocs instead of copying them
    By elnur, 5 years ago
  • Add support for input groups
    By elnur, 5 years ago
  • Append the classes set via the attr option for simple widgets
    By elnur, 5 years ago
  • Add instructions for rendering flash messages
    By elnur, 5 years ago
  • Use `lg` instead of `md` everywhere
    By elnur, 5 years ago
  • Add a missing article
    By elnur, 5 years ago
  • Reduce duplication
    By elnur, 5 years ago
  • Add basic information on form layouts
    By elnur, 5 years ago
  • Use a more appropriate word
    By elnur, 5 years ago
  • Add installation instructions
    By elnur, 5 years ago
  • Add a README file with basic information
    By elnur, 5 years ago
  • Do not add styling to the file type
    By elnur, 5 years ago
  • Add styling for the checkbox type
    By elnur, 5 years ago
  • Remove duplicating block names from the endblock tags
    By elnur, 5 years ago
  • Do not prevent addition of extra classes to textarea widgets
    By elnur, 5 years ago
  • Add description to the package
    By elnur, 5 years ago
  • Add Twig Bridge as a requirement
    By elnur, 5 years ago