PHP code example of slinstj / yii2-simple-feedback
1. Go to this page and download the library: Download slinstj/yii2-simple-feedback library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
slinstj / yii2-simple-feedback example snippets
composer
// in myview.php
use \slinstj\widgets\SimpleFeedback\SimpleFeedbackWidget;
// SiteController
...
public function actions()
{
return [
'rating' => [
'class' => 'slinstj\widgets\SimpleFeedback\actions\RatingAction',
],
];
}
// IMPORTANT:
// Please, refer to public attributes docblocks either in SimpleFeedbackWidget
// and SimpleFeedbackModel to see all available options.
<?= SimpleFeedbackWidget::widget([
'formAction' => ['my-controller/my-custom-rating-action'],
'isRatingAvailable' => true,
'isCommentAvailable' => false,
'modelConfigs' => [
'dbConfigName' => 'other_db_config',
'dbTable' => 'my_custom_table',
...
// using a callback but could be just a string
'targetValue' => function($model) {
// do your logic to define the target value
return \Yii::$app->params['something'];
}
],
])
// in myview.php
use \slinstj\widgets\SimpleFeedback\SimpleFeedbackWidget;
// MyController <<<
...
public function actions()
{
return [
'rating' => [
'class' => 'slinstj\widgets\SimpleFeedback\actions\RatingAction',
],
// MyController
...
public function actions()
{
return [
'rating' => [
'class' => 'slinstj\widgets\SimpleFeedback\actions\RatingAction',
'modelConfigs' => [
'dbTable' => 'my_custom_table',
'targetValue' => function($model) {
// do your logic to define the target value
return \Yii::$app->params['something'];
}
],
],
// MyController
...
public function myInlineAction()
{
$model = new SimpleFeedbackModel([
'dbTable' => 'my_custom_table',
'targetValue' => function($model) {
// do your logic to define the target value
return \Yii::$app->params['something'];
}
]);
...
}
// in your view
use \slinstj\widgets\SimpleFeedback\SimpleFeedbackWidget;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.