Form inputs to user attributes
Permalink 1 user found helpful
Is there anyway to get a submitted form's inputs saved into a user's attributes? For example, I have form fields with labels "Model" and "Serial No." When a customer submits the form, it automatically saves it as that user's attributes also named "Model" and "Serial No." Of course those user attributes would be only visible by admins in the backend.
Any help or alternative solution is appreciated.
Any help or alternative solution is appreciated.
Thanks. Yeah, this is geared towards registered users. Ok, I got to learn a bit about external forms. I'm getting the hang of it. I followed Andrew's tut on the link you posted, and if I stick in the code you gave me in the external form (line 3), Model Name always gets replaced by iPhone4. How can I get it so that any value submitted in a textfield will replace the previous attribute in "model_name"?
$u = new User(); $ui = $ui = UserInfo::getByID($u->getUserID()); $ui->setAttribute("model_name", $this->post('model_name'));
I stuck the above in a newly created function in a custom controller. It does update my attribute exactly the way I want it to. Thanks for the lead. Andrew's Howto on MVC helped as well. I guess all I gotta do now is add validation and confirmations and stuff. I believe I'm on the right track now.
You can write a template for an external form and then use the UI helper to update the user.
This code is assuming the user you want to update is logged on:
The model_name is where you'd place the attribute key that you setup in the dashboard, you'd change "iPhone 4" for your corresponding post data.
More information on using the User & User Info classes is here:
http://www.concrete5.org/documentation/developers/permissions/users...
Theres a short example of how to build custom forms here:
http://www.concrete5.org/community/forums/chat/external_forms_file_...
Oliver