kl83/yii2-rating-widget

允许您为某个东西设置星级评价或显示它。

安装: 88

依赖: 0

建议者: 0

安全: 0

星级: 1

关注者: 3

分支: 1

开放问题: 0

语言:JavaScript

类型:yii2-extension

v2.0.1 2018-09-09 09:38 UTC

This package is auto-updated.

Last update: 2024-09-09 23:03:46 UTC


README

Latest Stable Version Total Downloads License

允许您为某个东西设置星级评价或显示它。

安装

安装此扩展的首选方式是通过composer

运行以下命令之一

php composer.phar require kl83/yii2-rating-widget ^2.0

"kl83/yii2-rating-widget": "^2.0"

将以下内容添加到您的composer.json文件的要求部分。

使用方法

使用FontAwesome资产来显示星级。当前使用版本为4.7。如果您在项目中没有它,必须注册\kl83\widgets\RatingWidgetFaAsset资产。

\kl83\widgets\RatingWidgetFaAsset::register(\Yii::$app->view);

输入小部件

$form->field($model, 'rating')->widget('kl83\widgets\RatingInput', [
    'containerOptions' => ['class' => 'some-class'], // HTML attributes
    'maxRating' => 10, // stars count, default - 5
]);
// Sets 5 stars rating
jQuery('.widget').ratingInput('set', 5);

显示小部件

\kl83\widgets\RatingWidget::widget([
    'maxRating' => 10, // stars count, default - 5
    'options' => ['class' => 'some-class'], // HTML attributes
    'value' => 4.5, // highlighted stars count
]);
// Initialize widget
jQuery('.widget').ratingWidget();
// Sets 5 stars rating
jQuery('.widget').ratingWidget('set', 5);

许可证

MIT许可证