caio-brendo/rating-input

There is no license information available for the latest version (v1.0.1) of this package.

Componente que renderiza estrelas para seleção, bastante útil para trabalhar com avaliações.

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.0.1 2021-01-10 13:31 UTC

This package is auto-updated.

Last update: 2024-05-11 10:01:07 UTC


README

Rating Input


Rating input is a widget for yii2 framework to render a input for rating.

Latest Stable Version Total Downloads

DIRECTORY STRUCTURE

  src/             contains source code of widget
  src/assets       contains assets definition
  src/views        contains view files

REQUIREMENTS

The minimum requirement by this project template that your Web server supports PHP 5.6.0.

INSTALLATION

Install via Composer

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this widget using the following command:

composer require caio-brendo/rating-input

USAGE

With model

If you have a model, you can use the following code:

<?php 
use yii\widgets\ActiveForm;
use caiobrendo\Rating;
$form = ActiveForm::begin(['id' => 'rating-form']); ?>
    <div class="row">
        <div class="col-md-12">
            <?= $form->field($model, 'rating')->widget(Rating::class) ?>
        </div>     
    </div>
ActiveForm::end();

Without model

If you don't have a model, you can use the following code:

<?php 
use caiobrendo\Rating;
?>
    <div class="row">
        <div class="col-md-12">
            <?= Rating::widget([
                'name' => 'rating',
                'id' => 'rating-id'
            ])?>
        </div>     
    </div>

JAVASCRIPT EVENTS

$('.input-rating').on('beforeChange', (event) => {
    console.log('beforeChange', event);
})

$('.input-rating').on('afterChange', (event) => {
    console.log('afterChange', event);
})

SETTINGS

The widget supports all parameters that one would pass for any Yii Input Widget. The additional parameter settings specially available for the rating input widget configuration are:

  • model: The model for rendering input.
  • attribute: The attribute for rendering input.
  • value: The initial or actual value of the rating.
  • name: The name of the entry. This is used for modelless widget.
  • qtdStar: Star quantity to be selected;
  • starHeight: Height for star. Must be a valid css height.
  • starSpace: Space between the stars. Must be a valid css.