DevtimeRatingBundle
DevtimeRatingBundle copied to clipboard
This bundle provides a rating form field type for your Symfony2 project. It uses the jquery raty plugin.
How to Install
- Add this bundle to your vendor dir
* Vendor Mode
Add the following lines in your deps file:
[DevtimeRatingBundle]
git=git://github.com/gigo6000/DevtimeRatingBundle.git
target=/bundles/Devtime/RatingBundle
Run the vendor script:
./bin/vendors install
* Submodule Mode
$ git submodule add git://github.com/gigo6000/DevtimeRatingBundle.git vendor/bundles/Devtime/RatingBundle
-
Add the "Devtime" namespace to your autoloader:
// app/autoload.php $loader->registerNamespaces(array( 'Devtime' => DIR.'/../vendor/bundles', // your other namespaces ));
-
Add the "Devtime" namespace to your autoloader:
// app/ApplicationKernel.php public function registerBundles() { return array( // ... new Devtime\RatingBundle\DevtimeRatingBundle(), // ... ); }
-
Add the twig form configuration:
// app/config/config.yml
Twig Configuration
twig: form: resources: - 'DevtimeRatingBundle:Form:field.html.twig'
-
Copy the plugin images in your web dir:
- TODO: make this work with app/console assets:install
Create a dir called web/bundles/devtimerating/images
Copy all the files from src/Devtime/RatingBundle/Resources/public/images/* to web/bundles/devtimerating/images
-
Include jquery and raty plugin in your Twig template
Add this lines to your twig template
{% javascripts '@DevtimeRatingBundle/Resources/public/js/jquery.min.js' '@DevtimeRatingBundle/Resources/public/js/jquery.raty.js' %}
{% endjavascripts %}
How to use it in your form
Add the "rating" type to field you want to use as a rating.
...
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('rating', 'rating')
->add('comment')
;
}
Additional info
Raty plugin (examples) http://www.wbotelhos.com/raty/
*TODO : Document all the available options