-
- 1,118 Posts
Hi guys. I have a member registration form on my new site using Login Register. I have a number of elements in the form which require the member to multi-select an answer - e.g. where are you looking for work: London, South West, Scotland etc etc... What is the best way to do this? I had hoped using a multiple select html input would work (e.g. select dropdown, which allows user to multi-select options), but it appears, only one of the selected items gets passed on member registration - e.g. when I check the member in the MODx manager, always only one of the selected items is saved... Are checkboxes better?
Oh... and I also need to allow the member to upload a file as part of their registration... Is this possible? I have a file input in the form, but all that is saved and store on registration is the filename... not the file...
Any advice please?
Cheers
dubbs.
-
- 24,544 Posts
You might look at the Subscribe extra. It wraps the Register snippet and makes thing a lot easier. It provides checkboxes for you and saves the values automatically in either the comment field of the User Profile (comma-separated), or in your choice of extended field.
It's also more secure than Register, imo.
-
- 1,118 Posts
Bob - will that also handle file uploading?
-
- 24,544 Posts
No, I'm afraid not, though you might be able to add the FileUpload snippet.
-
- 1,154 Posts
I handle file uploading through the update profile snippet, in my case avatars. I do this as a second step of registering, I think its register -> confirm email -> populate profile and upload pic
-
- 24,544 Posts
I think that would take a custom hook.
-
- 24,544 Posts
What do the results look like when you submit the form? If the options all have the same name, they will come through as an array based on the 'name' in the form.
If the page posts to itself, you can put a snippet at the top with this code:
echo print_r($_POST['nameOfField']); It will be empty when the form loads, but it should display the user's choices on submission. If it does, I think the hook will have a reference to the user object, so this should work:
$profile = $user->getOne('Profile');
if ($profile) {
$extended = $profile->get('extended');
$variableFromForm = $hook->getValue('variableFromForm');
$extended['somefield'] = implode(',', $variableFromForm);
$extended->save();
}