-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom profile and FAQ ;) #10
Comments
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 :) |
OK, the basic example: user profile table with collumns: id
id => 1 Thats it, you now have some additional profile information for user with id "37" |
ok, that's the place i know ;) |
For registration
|
If it's not helping, I'll create example tomorrow |
ok so:
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');
}
}
'UserManagmentModule' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'registrationFormClass' => 'app\models\UserProfile',
],
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>
<?= $form->field($model, 'name')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
<?= $form->field($model, 'number')->passwordInput(['maxlength' => 255, 'autocomplete'=>'off']) ?>
Getting unknown property: webvimark\modules\UserManagement\models\User::name and now what to do? :D |
Awww, man it's easier for me to make example. |
ok, so i will wait for your example :) |
ok, when the example will be done?;) |
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 |
Can you manage to do it till Sunday? :) it's blocking issue in my project :( |
Ok, will do it tomorrow |
You may see example here now - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration |
Sorry, I just noticed that I didn't upload last update to github (so example will not work) :( |
OK :) i will wait :) |
Aaaand now it should work :) |
Ok, now it works :) thanks :) |
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. |
Try add this field to rules |
Actually i hv 3 custome fields which I have added to rules n User class i.e. [['name', 'phone','school_id'],'required'], |
Try echo "<pre>";
var_dump($model->errors);
echo "</pre>"; And see what errors you have |
I have done it with something like this:
and app\models\User.php
and override user controller in this way:
and it works without touching vendor module ;) |
@glanisko, thanks buddy....your solution worked but only while updating a user. During creation [name,phone,school_id] doesnt get inserted into table :( |
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. |
I know it is in FAQ, but after I have read the instructions - I could not do it. I have created user_profile table and ... I now get stuck.
Could you add more code how to create custom profile fields without changing module?
The text was updated successfully, but these errors were encountered: