This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
OctoberCMS-Developer
Created a seprate plugin with name profile and here is my boot code.
public function boot()
{
UserModel::extend(function() {
$model->hasOne['profile'] = ['Acme\Profile\Models\Profile'];
});
UsersController::extendFormFields(function($form, $model, $context) {
// if (!$model->exists)
// return;
if (!$model instanceof UserModel) {
return;
}
// To ensure if method exist in model
ProfileModel::getFromUser($model);
$form->addTabFields([
'profile[language]' => [
'label' => 'Language',
'tab' => 'profile',
'type'=> 'text'
],
// 'profile[currency_preference]' => [
// 'label' => 'Currency',
// 'tab' => 'Preferences',
// 'type' => 'text',
// 'type' => 'dropdown',
// 'dependsOn' => 'country'
// ],
// 'profile[homepage_preference]' => [
// 'label' => 'Homepage',
// 'tab' => 'Preferences',
// 'type' => 'text',
// 'type' => 'dropdown',
// 'dependsOn' => 'page'
// ],
]);
});
}
Created a relationship in a profile plugin
public $belongsTo = [
'user' => 'RainLab\User\Models\User'
];
Whenever I am saving it it says following error.
Unexpected type of array when attempting to save attribute "profile", try adding it to the $jsonable property." on line 519 of
Even I added the following code in model
protected $jsonable = [
'profile'
];
1-1 of 1