Download the PHP package cristianoc72/icon-button without Composer
On this page you can find all versions of the php package cristianoc72/icon-button. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cristianoc72/icon-button
More information about cristianoc72/icon-button
Files in cristianoc72/icon-button
Package icon-button
Short Description Simple extension for Symfony Form library, to apply icons to buttons
License MIT
Informations about the package icon-button
Icon-button
Icon-button is an extension for Symfony Form button and submit types. You can easily add an icon to your buttons, after or before the label.
By now, only Bootstrap Glyphicons are supported.
Installation
Install this package via composer:
Working with Silex
Be sure you've enabled TwigServiceProvider
and FormServiceProvider
and all its dependencies. See http://silex.sensiolabs.org/doc/providers/form.html.
Then register the extension in your Application:
and tell Twig about the icon-button template;
Working with Symfony
Register the extension as a service:
Usage
Icon-button extension adds two new properties to Symfony button type: icon
and icon_position
.
icon
property is a string containing the glyphicon css selector for the icon.
You can display your icon before or after the button label, by setting icon-position
property.
icon_position
accepts one of the following values: after
, before
, 0, 1 (0 means 'before' and 1 means 'after'):
And this is the result:
If you prefer the icon before the label:
And the result is the following:
When you're working on a multi step form wizard, you always define a previous step button and a next step button.
When you add a button named previous_step
or next_step
to your form, this extension automatically adds an icon as follow:
- previous_step :
icon
is set toglyphicon-step-backward
andicon_position
is set tobefore
- next_step :
icon
is set toglyphicon-step-forward
andicon_position
is set toafter
So that, if you're satisfied of the default icons, you can simply write:
And this is the resulting buttons:
If you need a reset
button too, it's put between previous and next buttons:
And here it is:
Tests
This library uses PhpUnit for testing. To run the test suite, from your project root directory, do:
Contribution
Each contribution is wellcome! A typo (expecially about my awful English), a bug fix, an addiction, a suggestion, everything is important.
If you want to contribute, simply fork this repository and submit a pull request.
Of course, there are a few little conventions to follow, before submitting a pull request:
- This project follows PSR-1 and PSR-2 coding standards. If you add or modify the code, we recommend to run
php-cs-fixer.phar
. See http://cs.sensiolabs.org. - When you modify the existent code, run the test suite and enjoy everything is green.
- When you add a new feature, write a test which proves that your code works fine.
License
This library is released under the MIT license. See LICENSE file for details.
All versions of icon-button with dependencies
symfony/form Version ^3.0
symfony/twig-bridge Version ^3.0
symfony/translation Version ^3.0