Opened 9 years ago
Closed 9 years ago
#6751 closed enhancement (fixed)
Extended profile checkbox defaults are overly enthusiastic.
Reported by: | dcavins | Owned by: | dcavins |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.4.0 |
Component: | Extended Profile | Keywords: | has-patch |
Cc: | dcavins |
Description
If there's a default value set for a checkbox, it is pre-selected when users first encounter the form. (That seems good.) But if a user selects none of the options so that an empty array is saved to the db, then every time the user edits that profile field group, the default option is pre-selected again. Like the form is saying "Are you SURE you don't want to pick this option?"
I've attached a patch that attempts to differentiate one null value from another by checking the return value type from BP_XProfile_ProfileData::get_value_byid()
, which appears to return an empty array if there is a saved value that is empty (no options selected) vs an empty string if no value exists for that field/user combination.
Attachments (2)
Change History (7)
#1
@
9 years ago
- Milestone changed from Awaiting Review to 2.5
- Owner set to dcavins
- Status changed from new to assigned
Approach looks good to me. Tiny nitpick: multiline inline comments should look like
/* * Foo bar. * * Note the single (not double) asterisk on the first line of the comment. */
#2
@
9 years ago
Thanks for looking this over @boonebgorges. Does it make sense to apply similar logic to non-required radio button groups? (There's some extra logic for radio buttons if they're required fields.)
As is, if a user clicks "clear" on a radio button group then saves the form, when the form reloads, the default is pre-selected all over again. I'm guessing that if the radio group is required, and no option is selected, the default should be selected.
#3
@
9 years ago
As is, if a user clicks "clear" on a radio button group then saves the form, when the form reloads, the default is pre-selected all over again. I'm guessing that if the radio group is required, and no option is selected, the default should be selected.
Yeah, this seems correct to me. We shouldn't be allowing null radio buttons.
#4
@
9 years ago
I've updated the patch to include better comments
I also explored adding a similar check to radio buttons. Unfortunately, the radio button save routine removes the corresponding wp_bp_xprofile_data
row if no option is selected, so there's no way I can think of to separate intentionally empty values from the case where no value has been set yet. When you edit a profile field group with radio buttons, you'll either need to select one or click "clear" to renew your abstention every time you fill out the form.
I'll let this patch float a few days then commit it. Thanks again for your feedback.
Differentiate when the user has selected none of the options versus when the user has not yet saved a value for this field.