PHP code example of misterspelik / yii2-role-activeform
1. Go to this page and download the library: Download misterspelik/yii2-role-activeform 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/ */
misterspelik / yii2-role-activeform example snippets
public function roleRules()
{
return [
[
'allow' => true,
'attributes' => ['*'],
'roles' => ['admin']
],
[
'allow' => false,
'attributes' => ['name'],
'roles' => ['manager']
],
];
}
use misterspelik\widgets\RoleActiveForm;
$form = RoleActiveForm::begin([
'role' => 'manager' //current user role
]);
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
// some code here
RoleActiveForm::end();