1

Maybe this is a "duh" moment for me and I'm missing the obvious but I have an exp:user:edit form setup where none of the checkbox fields get updated when posting the form. Here is an example line of code...

<input type="checkbox" name="notify_how_email" class="no_float" value="n" {if notify_how_email == 'y'}checked="checked"{/if} /> <label for="notify_how_email">Notify via Email</label>

I've also added the following on the recommendation from another solution but fields are still not updated...

<input type="hidden" name="XID" value="{XID_HASH}">

We are using Exp Eng 2.7.2 and User module 3.4.4 and Friends 1.6.2

Is there any special coding I need to do to set the custom fields to 'y' or 'n'? This is also happening with radio fields.

When I use the control panel to edit the profile the field content shows up on the form but with a checkbox I can't change it from checked to unchecked.

Thanks, Bob

4

This has been a common gripe with ExpressionEngine for years.

Here's a hack that I find works:

<input type="hidden" name="custom_fieldname" value="n" />
<input type="checkbox" name="custom_fieldname" value="y" {if custom_fieldname == "y"}checked="checked"{/if}>Bla bla</input> 

The first value sets the field to "n". If the user checks the box, then the value will be overwritten with "y".

This hack is also referenced at the end of this post from the ExpEng forums from way back in 2007. If you're brave, the post documents how to hack the Member Template to allow checkboxes. Personally, event though it's a bit verbose, I'd prefer simply adding the extra hidden field.

| improve this answer | |
  • Thanks for the info. I was hoping to avoid the use of hidden fields and thought that this latest version of the User module might have a way of handling this without the hidden fields. – Bob Foster Dec 21 '13 at 23:33
  • This is more how HTML works in general. Unchecked checkboxes are not considered in the submit data (i.e. no data is sent for that field), so if you need to send "n", you need that hidden field, and the following checkbox field to override the "n" if the checkbox is checked. The same applies for any general HTML form in which you want to send data for unchecked checkbox fields. – Solspace Dec 24 '13 at 18:20
3

The User:Edit tag only allows updating of the fields mentioned in the documentation: http://www.solspace.com/docs/user/edit/#form_fields

notify_how_email is not a valid option. Are you sure this is even a valid EE option (natively)? If so, what is it supposed to do?

| improve this answer | |
  • Thanks for the comment. notify_how_email is a custom member profile field that was added. I thought that custom member profile fields were also covered, as indicated in the Solspace documentation. solspace.com/docs/user/edit/#f_member_field_short_name – Bob Foster Dec 21 '13 at 23:31
  • They are. notify_how_email would be valid if there's a custom member field with that name. To use a custom field as a checkbox however, I would follow the solution above by nageeb. – Solspace Dec 24 '13 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.