DevtimeRatingBundle icon indicating copy to clipboard operation
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

  1. 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
  1. Add the "Devtime" namespace to your autoloader:

    // app/autoload.php $loader->registerNamespaces(array( 'Devtime' => DIR.'/../vendor/bundles', // your other namespaces ));

  2. Add the "Devtime" namespace to your autoloader:

    // app/ApplicationKernel.php public function registerBundles() { return array( // ... new Devtime\RatingBundle\DevtimeRatingBundle(), // ... ); }

  3. Add the twig form configuration:

    // app/config/config.yml

    Twig Configuration

    twig: form: resources: - 'DevtimeRatingBundle:Form:field.html.twig'

  4. 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

  5. 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