Will do. 😊
After the pointers regarding which files to mod, it was actually surprisingly easy. Makes me wonder why the functionality isn’t already there in EE proper if a muppet like myself can hack it???
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
September 06, 2007 6:20pm
Subscribe [9]#16 / Sep 10, 2007 6:49pm
Will do. 😊
After the pointers regarding which files to mod, it was actually surprisingly easy. Makes me wonder why the functionality isn’t already there in EE proper if a muppet like myself can hack it???
#17 / Sep 10, 2007 7:27pm
This thread is now summarised in a wiki article. Hope it reads ok!
• Enable radio buttons and checkboxes for custom member profile fields.
#18 / Sep 10, 2007 7:42pm
Thank you, Nathan!
#19 / Sep 11, 2007 12:35pm
Ok, one final (maybe) question for you. Is there ‘any’ way via a hack that I can display some content on the register and edit profile templates (profile_theme.php) when a certain custom field ID is the current custom field row.
For example, I wish to interrupt the flow of custom fields that EE spits out onto the page with a seperator.
#20 / Sep 20, 2007 6:33pm
I found a workaround to allow me to display field separators by adding another ‘field type’ of ‘none’ in the same format as my hack to add checkboxes and radio buttons. The ‘none’ field type returns a seperator which includes a sub title for that area of the form. 😊
#21 / Oct 16, 2007 10:44pm
Hi, thanks for this.
First of all, I’m trying this is a standalone registration form and having an issue with a single field that needs multiple checkboxes. Not sure how to properly render checkboxes for one field other than giving them all the same name - but only the last value is kept. My field ID for this field is m_field_id_11 - but your code (was reading the Wiki) shows this as the last step:
$checkboxes = array("m_field_id_1");
foreach ($checkboxes as $checkbox_field)
{
if (!isset($_POST[$checkbox_field])) {
$_POST[$checkbox_field] = "n";
}
}What exactly is that doing? Should I change that ‘m_field_id_1’ to ‘m_field_id_11’? And what if I have more than one field where that I’ve designated as checkbox?
The radio button seems to work fine (m_field_id_10 in my DB), and a field with a single checkbox seems to work fine (m_field_id_9), but I have 9 selections I need people to choose from (m_field_id_11). Here’s some sample code:
<label><input name="m_field_id_11" type="checkbox" value="whatever1" /> whatever1</label>
<label><input name="m_field_id_11" type="checkbox" value="whatever2" /> whatever2</label>
<label><input name="m_field_id_11" type="checkbox" value="whatever3" /> whatever3</label>If I select ‘1’ and ‘3’ right now, only ‘3’ gets stored in the DB.
I guess I need to ask too: where am I storing the values whatever1, whatever2, and whatever3?
One last thing: You say “To add a field that will be used as a checkbox use the ‘text’ type” - does that mean text input or textarea?
#22 / Oct 17, 2007 1:42pm
OK, I figured out the first part, I think. I need to add every field that has a type of ‘checkbox’. So my variable/array will look like:
$checkboxes = array("m_field_id_9,m_field_id_11");because I currently have two checkbox fields. (Yes, I should have read this thread a little more carefully…)
The second part of my post is still a little fuzzy for me. Can I make a single field with type of ‘checkbox’ and store multiple values? For example, a field called “Interests” that has 3 possible choices. I assume the code would look like so:
<label><input name="m_field_id_11[]" type="checkbox" value="whatever1" /> whatever1</label>
<label><input name="m_field_id_11[]" type="checkbox" value="whatever2" /> whatever2</label>
<label><input name="m_field_id_11[]" type="checkbox" value="whatever3" /> whatever3</label>OR: do all of the choices themselves (whatever1, whatever2, etc) need to be custom fields set to type ‘checkbox’? Which means my checkbox array would look more like this:
$checkboxes = array("m_field_id_9,m_field_id_11,m_field_id_12,m_field_id_13");and the markup would look more like:
<label><input name="m_field_id_11" type="checkbox" value="whatever1" /> whatever1</label>
<label><input name="m_field_id_12" type="checkbox" value="whatever2" /> whatever2</label>
<label><input name="m_field_id_13" type="checkbox" value="whatever3" /> whatever3</label>Just not sure which way I need to go with this, and I’m starting to think it’s the latter, because I’m not sure how you would populate the multiple checkbox choices in the first example, if they’re not pulling from the field name. Thanks for your help!
#23 / Oct 17, 2007 2:50pm
If I use the first method “m_field_id_11[]” (with the brackets), check 2-3 checkboxes on my form, and use phpMyAdmin to view what gets stored in that field, it says “Array”. Is that correct behavior? If so…cool…I can store all my related values in one field - as long as I can figure out how then read that array. Anyone? I hear crickets in here 😊.
#24 / Oct 17, 2007 3:11pm
i’m listening…. this is going to be my weekend project.
#25 / Oct 17, 2007 9:25pm
You are correct, the method I took was to have a seperate custom profile field for each checkbox. However if you have managed to store an array on the DB field you could pulling it out with raw PHP or the SQL Query module to see what it contains. Just do a ‘print_r($variable_name);’
😊
#26 / Oct 17, 2007 9:26pm
i’m listening…. this is going to be my weekend project.
If you do manage to get something up and running please post your results back here! 😊
#27 / Oct 17, 2007 9:42pm
I made each choice its own field. Just easier that way! Now this part of my project is done! Thanks for taking the time to document this hack.
#28 / Oct 18, 2007 8:33am
No worries, glad that it worked for you too! Here’s hoping that EE 2 might have these features built in! 😊
#29 / Oct 21, 2007 11:16am
Thanks for this code!!! It’s just what I need.
However, I have one small thing that is not working though.
When the user goes to their profile to update their checkbox, the check/uncheck does not update the database. I think there might be something to do with the m_field_id_1. Do I need to change m_field_id_1 to match the m_field_name I gave this field the exp_member_fields table?
You can see the functionality yourself if you wish at: babybloomermagazine.com/magazine/
Again, thanks for this!
Michael
#30 / Nov 27, 2007 9:12am
Bit of an update on this thread. I just started using the ‘Solspace User Module’ and this is really worth checking out. It takes a huge amount of pain out of working with member features becuase you can do pretty much everything using standard EE templates. Woot!