Comments (25)
For registration
-
In config file you can redefine "registrationFormClass" property, so you need create your own registration from class (just copy-paste existsing and modify it for your needs)
-
Use theming for registration view file
-
....
-
Profit ? :)
from user-management.
Basically you create some "profile" table witch has "user_id" as foreign key to "user" table. And the you just run gii generators.
P.S. I know that FAQ is needed, but right now I have not so much spare time :)
from user-management.
OK, the basic example:
user profile table with collumns:
id
user_id
age
pet_name
- Generate model UserProfile via gii somewhere in your app.
- Generate crud for this model via gii
- Now you can add data to this table. Lets say it will looks like this:
id => 1
user_id => 37
age => 8
pet_name => "Doggy"
Thats it, you now have some additional profile information for user with id "37"
from user-management.
ok, that's the place i know ;)
how merge this information to registration form, save them with user save on user-management/user/create ? ;)
from user-management.
If it's not helping, I'll create example tomorrow
from user-management.
ok so:
- i have created table: user_profile
class m150130_190352_create_user_profile extends Migration
{
public function up()
{
$this->createTable('user_profile', [
'user_id' => 'pk',
'name' => Schema::TYPE_STRING . ' NOT NULL',
'number' => Schema::TYPE_STRING . ' NOT NULL',
]);
$this->addForeignKey('fk_user_id', 'user_profile', 'user_id', 'user', 'id');
}
}
- generated model and crud controller
- added to conmponents config section
'UserManagmentModule' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'registrationFormClass' => 'app\models\UserProfile',
],
- copied view file to my repository
use webvimark\modules\UserManagement\models\User;
use webvimark\modules\UserManagement\UserManagementModule;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use webvimark\extensions\BootstrapSwitch\BootstrapSwitch;
/**
* @var yii\web\View $this
* @var webvimark\modules\UserManagement\models\User $model
* @var yii\bootstrap\ActiveForm $form
*/
?>
<div class="user-form">
<?php $form = ActiveForm::begin([
'id'=>'user',
'layout'=>'horizontal',
'validateOnBlur' => false,
]); ?>
<?= $form->field($model->loadDefaultValues(), 'status')
->dropDownList(User::getStatusList()) ?>
<?= $form->field($model, 'username')->textInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
<?php if ( $model->isNewRecord ): ?>
<?= $form->field($model, 'password')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
<?= $form->field($model, 'repeat_password')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
<?php endif; ?>
<?php if ( User::hasPermission('bindUserToIp') ): ?>
<?= $form->field($model, 'bind_to_ip')
->textInput(['maxlength' => 255])
->hint(UserManagementModule::t('back','For example: 123.34.56.78, 168.111.192.12')) ?>
<?php endif; ?>
<?php if ( User::hasPermission('editUserEmail') ): ?>
<?= $form->field($model, 'email')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'email_confirmed')->checkbox() ?>
<?php endif; ?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<?php if ( $model->isNewRecord ): ?>
<?= Html::submitButton(
'<span class="glyphicon glyphicon-plus-sign"></span> ' . UserManagementModule::t('back', 'Create'),
['class' => 'btn btn-success']
) ?>
<?php else: ?>
<?= Html::submitButton(
'<span class="glyphicon glyphicon-ok"></span> ' . UserManagementModule::t('back', 'Save'),
['class' => 'btn btn-primary']
) ?>
<?php endif; ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
- added two fileds to copied file in step 4
<?= $form->field($model, 'name')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
<?= $form->field($model, 'number')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
- get Unknown Property Exception ;)
Getting unknown property: webvimark\modules\UserManagement\models\User::name
and now what to do? :D
from user-management.
Awww, man it's easier for me to make example.
You do it wrong :0
from user-management.
ok, so i will wait for your example :)
from user-management.
ok, when the example will be done?;)
from user-management.
Have no time right now :( Probably will do it till Wednesday.
Here is the start - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration
from user-management.
Can you manage to do it till Sunday? :) it's blocking issue in my project :(
from user-management.
Ok, will do it tomorrow
from user-management.
You may see example here now - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration
from user-management.
Sorry, I just noticed that I didn't upload last update to github (so example will not work) :(
Will do it when I'll be at home
from user-management.
OK :) i will wait :)
from user-management.
Aaaand now it should work :)
from user-management.
Ok, now it works :) thanks :)
from user-management.
I want the User table to have a custom field i.e. school_id. I added to table, then to views and to webvimark\modules\UserManagement\models\User model class, but its value is not saved/updated from your extension. I know I can use profile but I would rather prefer it via User table. Please guide me.
from user-management.
Try add this field to rules
from user-management.
Actually i hv 3 custome fields which I have added to rules n User class i.e. [['name', 'phone','school_id'],'required'],
from user-management.
Try
echo "<pre>";
var_dump($model->errors);
echo "</pre>";
And see what errors you have
from user-management.
I have done it with something like this:
config/web.php
'components' => [
'user' => [
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'identityClass' => 'app\models\User',
],
'view' => [
'theme' => [
'pathMap' => [
'@vendor/webvimark/module-user-management/views' => '@app/views/webvimark/module-user-management/',
'@vendor/webvimark/module-user-management/views/layouts/' => '@app/views/layouts/',
],
],
],
]
'modules'=>[
'user-management' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'controllerMap' => [
'user' => 'app\controllers\UserController',
],
],
],
and app\models\User.php
<?php
namespace app\models;
use webvimark\modules\UserManagement\models\User as BaseUser;
use yii;
/**
* @property string $name
* @property string $surname
* @property string $telephone
*/
class User extends BaseUser
{
/**
* @inheritdoc
*/
public function rules()
{
return ArrayHelper::merge(parent::rules(), [
[['name', 'surname'], 'required'],
[['name', 'surname', 'telephone'], 'string', 'max' => 255],
]);
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return ArrayHelper::merge(parent::attributeLabels(), [
'name' => Yii::t('app', 'Name'),
'surname' => Yii::t('app', 'Surname'),
'telephone'=> Yii::t('app', 'Telephone number'),
]);
}
}
and override user controller in this way:
<?php
namespace app\controllers;
use webvimark\modules\UserManagement\controllers\UserController as BaseUserController;
use Yii;
use yii\helpers\Url;
class UserController extends BaseUserController
{
public $modelClass = 'app\models\User';
public $modelSearchClass = 'app\models\UserSearch';
}
and it works without touching vendor module ;)
from user-management.
@glanisko, thanks buddy....your solution worked but only while updating a user. During creation [name,phone,school_id] doesnt get inserted into table :(
from user-management.
I was able to solve by making the following 2 changes in Webvimark User class:
- Added properties at the start of the class:
- Added to rules():
[['name','phone','school_id'], 'required'],
from user-management.
I have a Yii2 app where I want the registered and logged in user to edit his user table custom fields like name, company_name etc.
I created a view "my-account.php" inside vendor->webvimark->module-user-management->views/auth/ folder. I added an action fuction (actionMyAccount() ) in webvimark->module-user-management->controller->authController class.
I am able to pull and show user custom columns data on view but am unable to update that data. Help needed.
from user-management.
Related Issues (20)
- access based on time HOT 1
- Model overwriting HOT 1
- how to stop auto logout? HOT 3
- Is this repository discontinued? HOT 2
- migration failed... HOT 4
- PHP 7.3 compact() issues an E_NOTICE level error HOT 1
- only one login per device can active in one time
- mySQL errors
- DB error when overwriting table names
- How to disable captcha on user registration?
- Migration not working for OCI HOT 2
- hasRole() function doesnt work with children roles
- GhostAccessControl::rules does not exist
- How to combine ghost-access with custom permissions
- $throwException is missing HOT 2
- Issue with Unchecked Routes in Permissions
- PHP Notice on permissions save for PHP 7.4 HOT 3
- Broken Link in FAQs section HOT 1
- Password recovery HOT 1
- compact(): Undefined variable: throwException while saving permission
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from user-management.