I needed to "convert" a text field to a select and this module become useful and better than select_or_other, but I did need Other to be optional, as I don't want free addition to the text, but rather only elements within the range (when possible).
The attached solution makes the Other option optional, but only when possible.
The rationale behind this is that allowed values list can change over time and also be added on sites where there's already content there, so if the field data is not currently present on the allowed values list, the other field will still be available on that case.
Comments
Comment #2
hanoiiAttached is the patch for this functionality.
Comment #3
dagmarThanks for this patch. I have a few comments.
I don't think the description of the checkbox is accurate.
I think the title is could be better. What about. "Do not use custom value label."?
We could use drupal #states to hide the 'custom_value_label' field to enforce the meaning of this setting.
I'm not sure if hidden when possible reflects the reality of this code. I mean, there is no check to determine if is possible to hide it or not. So what about replace the $summary with. No "custom label enabled".
Comment #4
hanoiiI guess I attempted, agree on poorly, to convey that the "Other" option will still show in some circumstances, that is when there is content on the node (on edit) that's not currently on the settings for the select of this widget.
Otherwise it's confusing that you chose to hide it, but you still have to provide a Label for it. And this is because I didn't want to disable the label setting, as I do need it for this circumstances, although maybe for those cases it's best to simply default to
t('Other')and call it a day.Maybe what I just wrote makes more sense. What if I make the Value field optional, as if empty it's not going to be used, with the exception of the above.
Comment #5
dagmar+1
Something like?
Comment #6
hanoiinow?
PS: Hola!
Comment #7
hanoiiComment #8
hanoiiActually changed back one of the lines.
Comment #9
daggerhart commentedThis looks great and is a solid feature. Marking RTBC and will get it committed shortly.
Thanks!
Comment #11
daggerhart commentedCommited, thanks again!