This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

deroccha
deroccha

I've been extending the rainlab user plugin following the video Tutorial. This one works great from backend. Now I want to allow frontend user to edit and update profile specific data. How do I manage to get saved profile fields in component extending the user form?

ax2to
ax2to

I'm working in same issue, I think we need create a custom form.

daftspunky
daftspunky

You will need to create your own Component / AJAX handler to handle the introduced fields, see the Account component in RainLab.User for an example. It is used currently to update the user.

Mohsin
Mohsin

Easy way would be to make a new form that takes the frontend post request and updates the extended model's data with the new values.

I believe you cannot use the same onUpdate function to update the extended models data because there is one problem... The $user->save() only saves the data of the current model, whereas a push() would save the related models as well. So i suppose it's better that you write a new function onUpdate() with either a push() or something like

public function onUpdate()
{
$profile = // Do a where query to get the current row in profile model
$profile = post('headline'); // update the data with the data from the post
$profile -> save(); // Save the model
}

Last updated

Igor Jacaúna
Igor Jacaúna

I created a plugin that extends the User plugin. I followed the User Plus structure, and I added some fields in users table and I used this on my Plugin.php file to save the custom data:

UserModel::extend(function ($model){
        $model->addFillable([
            'birthdate',
        ]);
});

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.