PHP code example of marqu3s / yii2-behaviors
1. Go to this page and download the library: Download marqu3s/yii2-behaviors 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/ */
marqu3s / yii2-behaviors example snippets
public function behaviors()
{
return [
'saveGridPage' => [
'class' => SaveGridPaginationBehavior::class,
'sessionVarName' => self::class . 'GridPage',
'sessionPageSizeName' => self::class . 'GridPageSize'
]
];
}
$dataProvider = new ActiveDataProvider(
[
'query' => $query,
'sort' => ...,
'pagination' => [
'page' => $this->getGridPage(), // <- Prefered method
'pageSize' => $this->getGridPageSize(),
...
]
]
);
$dataProvider->pagination->page = $this->getGridPage();
public function behaviors()
{
return [
'saveGridFilters' => [
'class' => SaveGridFiltersBehavior::class,
'sessionVarName' => self::class . 'GridFilters'
]
];
}
$dataProvider = new ActiveDataProvider(
[
'query' => $query,
'sort' => ...,
'pagination' => [
'page' => $this->getGridPage(), // <- Prefered method
'pageSize' => $this->getGridPageSize(),
...
]
]
);
//$this->load($params); // <-- Replace or comment this
$dataProvider = $this->loadWithFilters($params, $dataProvider); // From SaveGridFiltersBehavior
public function behaviors()
{
return [
'saveGridOrder' => [
'class' => SaveGridOrderBehavior::class,
'sessionVarName' => self::class . 'GridOrder'
]
];
}
$dataProvider->sort->attributeOrders = $this->getGridOrder();
public function behaviors()
{
return [
'LogChanges' => [
'class' => LogChangesBehavior::class,
// Customization
'valuesReplacement' => [
'active' => [
0 => 'No',
1 => 'Yes',
]
],
'currencyAttributes' => [
'subtotal', 'total', 'tax'
]
],
];
}
php composer.phar