Hello,

I use Select or other for taxonomy. The functionality is OK so far.

Unfortunately, the label of the form is displayed twice.

Did you get the error already discovered?
I have in select_or_other.module (version = "7.x-3.x-dev") function: function select_or_other_element_process the line 94 is disabled (- '# title' => $ element ['# title'])

Now the label is present only once.

Would appreciate some feedback.

regards
Twuli

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huijing’s picture

My issue is sort of different. I am using the other option on a list of select options, and my issue is the label doesn't display at all. Inspecting source shows that there is an ".element-invisible" class on the label, and there are 2 of them, one which is the default label that is generated by webform and one is within the div generated by select or other.

I'm not sure how to patch this issue so I hacked a workaround via jquery (I'm so certain this is wrong, but I need it to work). Basically, I just removed ".element-invisible" from one of the labels using this:
$(".select-or-other .form-type-radios").find("label:first-of-type").removeClass("element-invisible");

I'd really like to know how this issue can be patched properly though.

legolasbo’s picture

Status: Active » Closed (cannot reproduce)

I'm unable to reproduce this issue with the latest development version. Please reopen and add clear steps to reproduce the problem if this is still an issue.

Adrian Richardson’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
1.39 KB

I am experiencing the original problem described by twuli when using the latest 3.x-dev version with webform 4.7. There is an extra rendering of a title label which does not include the required status. Webform uses webform_element for a theme wrapper on select elements instead of form_element so the hook_process_form_element is never called.

I'm attaching a patch which uses a pre_render callback to control the rendering of the title on only the original element (and not the created 'select' child element) together with the required status marker.

guster-von’s picture

I was seeing the same duplicate label occur on Webform.

It is gone after applying the patch.

Thanks!

bartmann’s picture

Not using Webform, but in the add node we were getting duplicate labels - patch has fixed this.

legolasbo’s picture

Issue tags: +Needs tests

Duplicate labels have been occurring several times over the history of this module. It would be great if a regression test could be added to prevent this from happening in the future.

legolasbo’s picture

Status: Needs review » Needs work
bkno’s picture

Patch works for me. Would be good for this to get committed.

legolasbo’s picture

Issue tags: +Quick fix

  • legolasbo committed 1642afb on 7.x-3.x
    #2165467 - Added regression tests for duplicate form labels.
    
legolasbo’s picture

Status: Needs work » Needs review
Issue tags: -Quick fix
FileSize
1.4 KB

Patch #3 did not apply correctly anymore so I had to reroll it. Let's see what testbot thinks about it with the new regression tests added in #10.

Also still needs tests for the webform integration.

Status: Needs review » Needs work

The last submitted patch, 11: the_label_of_the_form-2165467-11.patch, failed testing.

legolasbo’s picture

As I suspected, this patch breaks the existing functionality for non-webform elements and therefor needs work.

penone’s picture

Any update on this issue?

legolasbo’s picture

Not on my end. I've been busy with the D8 version. will probably end up backporting a lot of the work that has been done there, since it's been rebuilt from scratch, but I'm not sure if that would fix this issue. Haven't run into double labels in the D8 version though.

SaintNexcis’s picture

The patch on #3 worked for me in removing the double label, however I'd like to point out that the "extra label" is actually the label for the Other text field that appears when one selects Other. I believe this because prior to patching I could get it to only show ONE label as long as I didn't select the option to allow "Other...". If this is true (I haven't traced it in the code) then the label is being applied incorrectly as I would imagine that it should state Other, not the Parent Label.

Also, the patch worked for me by means of applying it manually... I'm currently running Version: 7.x-3.0-alpha1+18-dev.

DRIVE’s picture

Thought I saw a note that a patch was pushed to 7.x-3.x-dev. Applied #3 manually and all set. Thank you!

amh5514’s picture

#3 works after you manually applying the patch. There was a closing bracket the patch failed to remove with the function in the Pre-render callback section - around line 213

LIQUID VISUAL’s picture

I have two labels in select options field in webform if I enable the "or other" option. I'm using Select or other 7.x-3.0-alpha1+19-dev and Webform 7.x-4.14+25-dev. Example at http://conf.liquidvisual.ca/content/invitation-test-webform if anyone has tip or patch.

DRIVE’s picture

LIQUID VISUAL - https://www.drupal.org/node/2165467#comment-11874883 your test site is down

LIQUID VISUAL’s picture

This worked for me when I set up the fields correctly. Why do I have product variations but no product types? Is that normal?

Where can I find out why I am unable to make commerce products a translatable entity even though I have the right modules enabled? When I select Commerce Product to be a translatable entity, it does not appear as a tab in the lower left of the settings page.

FiNeX’s picture

Hi, with the patch the label is shown once but the input text box is always visible.

torotil’s picture

Status: Needs work » Needs review
FileSize
612 bytes

Here is a patch that implements a process callback for theme_webform_element().

Note that the existing comment for select_or_other_process_form_element() is actually wrong as this is not a hook but a theme process function.

alibama’s picture

@torotil - thank you = this fixed webform + select other for me