Some modules such as Name add more than one <label> element per form field. For example, if you set the name field label to show up "below" the field, it sets the normal label element to be visually hidden, and then adds an additional one beneath the field. The javascript for this module selects both labels and concatenates them to form the float label, resulting in the bug in the attached image.
One solution to get around this is to make sure the name field label is set to appear "above" the field - then it will only have one label element. To get around having to specify this in the module instructions, we can edit the JS to always select the first label returned by the var $label = $(element).closest('form').find('label[for=' + id + ']') selector.
Patch will follow shortly...
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | float_labels-fix_duplicate_float_labels-3120166-5.patch | 512 bytes | jbernthal |
| float_label-duplicate_label_bug.png | 6.18 KB | amklose |
Comments
Comment #2
amklosePatch...
Comment #3
amkloseComment #4
amkloseComment #5
jbernthal commentedI updated the patch - for some reason, the previous patch was working on one site, but on another, the $label variable was not being seen as a valid jQuery element, so the $label.length check failed, as well as the $label.text() call. To fix this, I wrapped the code used to select the corresponding label in a jQuery element wrapper to make sure it's the right type of object. I also removed the " > 0" in the $label length check as it's unnecessary.
Comment #6
amkloseBlagh - sorry - that last comment/patch was from me. I was logged in under the wrong account.
Comment #8
replicaobscuraThanks Tony!