The radios "Total submissions limit" as example is properly themed. All input boxes are inline.
"Redirection location" is not. It has the radio text and then the input has the normal DIV wrapper where only the input field should be a
Here we see how HTML should look like (radio + text + input + text + select, but no DIV wrappers around input and select):
<div class="form-item form-type-radio form-item-enforce-total-limit webform-container-inline">
<input type="radio" id="edit-enforce-total-limit-yes" name="enforce_total_limit" value="yes" class="form-radio"> Limit to <input class="ym-inline webform-set-active form-text" type="text" id="edit-total-submit-limit--2" name="total_submit_limit" value="" size="8" maxlength="8"> total submission(s) <select class="ym-inline webform-set-active form-select" id="edit-total-submit-interval" name="total_submit_interval"><option value="-1" selected="selected">ever</option><option value="3600">every hour</option><option value="86400">every day</option><option value="604800">every week</option></select>
</div>
</div>
<div class="description ym-message">Limit the total number of allowed submissions.</div>
</div>
And this is how "Redirection location" looks like:
<div class="form-item form-type-radio form-item-redirect webform-container-inline">
<input type="radio" id="edit-redirect-url" name="redirect" value="url" class="form-radio"> Custom URL:
<div class="form-item ym-fbox-text form-type-textfield form-item-redirect-url">
<input class="webform-set-active form-text" type="text" id="edit-redirect-url--2" name="redirect_url" value="" size="60" maxlength="255">
</div>
</div>

and this HTML code should be:
<div class="form-item form-type-radio form-item-redirect webform-container-inline">
<input type="radio" id="edit-redirect-url" name="redirect" value="url" class="form-radio"> Custom URL: <input class="webform-set-active form-text ym-inline" type="text" id="edit-redirect-url--2" name="redirect_url" value="" size="60" maxlength="255">
</div>
With this change the form looks correct like:

Comments
Comment #0.0
hass commenteda
Comment #1
quicksketchThanks, good suggestion. I haven't looked at how this is generated, but I imagine we could fix this by setting #theme_wrappers to an empty array.
Comment #2
hass commentedPatch attached
Comment #3
hass commentedCross post
Comment #4
hass commentedI'm injecting my inline class to the inline field via:
Comment #5
hass commentedNew patch. Removed some dev code.
Comment #6
hass commentedChange code order in theme function to match form array.
Comment #7
hass commentedSomething is wrong. If I click in the textfield the radio change to the last option?
Comment #8
hass commentedStrange... we need to move the input boxes into a label. This also affects all other radios.
Example:
Otherwise the last radio will be selected if you click into the redirect_url input box. This bug is only not visible in the other options as the input boxes are only on the last radio item.
Comment #9
hass commented*Hell*
theme_form_element_label()filters all label withfilter_xss_admin()and removes inputs that have been added to a title. I this the reason why it was implemented this way? This is really bad... we should clonetheme_form_element_label()and allowinput. Otherwise I have no idea how to solve this without changing core in a clean way. But I'm also not sure if this may lead to security issues as I guess there are reason for thisfilter_xss_admin().@quicksketch: what do you think?
Comment #10
hass commentedThis patch should do the trick.
Comment #11
hass commentedAlso allow select/option tags.
Comment #12
hass commentedAnd one damn manual line break because of Eclipse EGit bug.
FINAL.
Comment #13
quicksketchYeah I do recall having difficulty with the whole inline fields problem. You've probably already spent a ton of time figuring this out all over again, but this kind of UI pattern is not easy to accomplish in Drupal, which is too bad because it works so well.
We actually have some JS on the page that is doing the work of selecting the right options (in webform-admin.js, the Drupal.webform.setActive function). I think we actually should *not* put the input fields inside the labels because it causes problems with usability. Every time one of the fields gets focus inside a label, the matching radio button gets selected. This causes a problem when tabbing through the elements on the page with the tab key. It makes it so the radio option changes every time the field is tabbed-through, which we don't want.
Comment #14
hass commentedWhat's wrong with putting input in label? I've not seen this first, but if we do not use label the text color is also wrong. You see it in the screenshots. Label have a grey tone and the custom inline one from past has dark black. This styling issue is also fixed.
Comment #15
quicksketchTry using the keyboard to tab through the fields on the page. Last I tried this, every time a field received focus within the label, it caused the matching radio button to be selected, even if no value was entered. This made it difficult to select the first radio button and tab through the remaining fields without the intended choice being changed.
The styling being fixed is a good thing. If we can adjust our current JS to *prevent* this undesirable behavior, that would work. That matching JS code needs to be updated (or if things work without it, remove the JS).
Comment #16
hass commentedI'm unable to reproduce this. I tabbed through the form and it first selects the current selected radio and than I'm able to change the radio. Do you have a repro plan?`
LABEL have the
for=""attribute set and if you click on a label this radio get's selected. This is a normal behavior. The code you are writing about is this? We are able to remove this... I guess you added it to implement the LABEL auto selection feature for these non-label items we used in past!?Comment #17
hass commentedNew patch with more cleanup and also fixes some missed forms. Needs testing now.
Comment #18
quicksketchUpon testing, it looks like the problem I described no longer exists. After testing your patch, I tried IE8/10, Safari, Firefox, and Chrome. All of them worked great.
Yep, the code we have currently essentially duplicates what labels were supposed to do. It was a work-around when browsers had a troublesome behavior of selecting radio buttons merely by having fields within their labels receive focus.
Overall this looks really good. I'm going to take a hand at rerolling minor adjustments.
Comment #19
hass commentedNew patch. This one should really fix all fields now.
NOTE: Please note that this makes a lot of the very small patches to allow preprocess injection useless. They are automatically fixed by this patch as the class array is not written. Please give this one a shot first before following up with the RTBC patches.
Comment #20
quicksketchThanks @hass. I'll work on rerolling with this new patch. The changes I had in mind were:
- Keeping the webform-set-active class and updating the JS behavior so that it still selected the current radio button if a field were changed via keyboard. I'll change to using the class appending approach instead of assignment.
- The theme function theme_webform_element_label() is misleadingly named, since I would think that would be the label used for displaying Webform form labels, but in fact it's only used for displaying these inline radio button labels. I want to rename it to theme_webform_inline_radio_label() to match its actual usage. If we want a different theme function for labels displayed in Webform labels, then that should be a separate function (but right now I can't see any reason to do this).
Comment #21
quicksketchOne more thing, we can kill use of "webform-default-value" entirely and use $element['#attributes']['placeholder']. I think browser support is wide enough to make this acceptable at this point, similar to #1305826: Add support for HTML5 placeholder attribute. That's not entirely related to this issue but it's touching on some of the same code, I wouldn't mind killing it while in here.
This feature is currently marked at a 7.x-3.x issue. I don't like changing theme functions mid-cycle like this, and if it's 3.x then we need to backport these changes to 6.x-3.x too. Would you be okay with this being a 7.x-4.x only change?
Comment #22
quicksketchHere's my reroll, implementing my comments in #20 and #21.
Comment #23
hass commentedPatch looks code wise good to me. I just have not understood what the effect is with these set active class. How can I repro this for review?
It's more a bugfix to me and it only affects admin pages right now. I'd really like to get this in asap. What's the roadmap for 4.x? Currently it's alpha and this sounds like another year or more until final. In this case we should commit this to 3.x. I need a stable version that works well.
Comment #24
quicksketchThanks for looking it all over. I tested it again and I think this is good to go. It surprised me how many places in Webform we use this 3-radio-button approach.
So to reproduce the JS behavior, use the keyboard to tab down to the "Custom URL" (or other textfield) without changing the radio button. Then type a value into the field and tab out of it. The JS behavior will make it so that the radio button that matches the textfield/select list will be checked if a value has been entered. That makes it so keyboard-only users have a similar experience to mouse users, that when they enter a value the corresponding radio button is checked. For mouse users this happens on click, for keyboard users it will now happen on change.
Although it's marked alpha I only have it named as such so that I can continue changing the APIs, stability-wise there are fewer overall bugs than 3.x because the architecting has solved several long-standing problems in 3.x (i.e. proper token and conditional support). I wanted to rename "components" to "fields" but my informal surveying of users has indicated that they would only find that more confusing, so I don't think that will come to pass until something like #118984: Field API based rewrite of webform module happens (which would be Webform 5.x).
What I really don't want to have happen is nobody using Webform 4.x on Drupal 7 and ending up in a situation similar to Views 3 for Drupal 6. If the release is too late in the release cycle, nobody ends up using it and the "default" release stays on the previous version. So I'm motivated to make a final release of 4.x sooner rather than later so I don't have to maintain D6/D7 3.x branches in sync any more. It's the back-porting that's the real pain.
Comment #25
hass commentedUhhh... Views 3 key issue is mainly the broken upgrade path from 2.x and it looks like views maintainers do not really focus on getting this issue resolved first :-(((
I'm strongly for renaming components to fields!
Comment #26
hass commentedTested your patch with 4.x and it works like a charm. Also tested the tab navigation. RTBC.
Comment #27
quicksketchHah! I'm on the fence about it. "Components" is a terrible name we've had since Drupal 4.4. "Fields" is clearly a better name but it runs into obvious namespace conflicts with Field module and FormAPI. I made a new issue for official discussion: #2037581: [meta] Rename "components" to "fields"(?) Opinions Wanted
Comment #28
quicksketchCommitted #22 to 7.x-4.x. Thanks @hass!
Comment #29
hass commentedThx, let's get the form item preprocess theming in now... :-)
Comment #30
quicksketchHm, this patch broke using tokens in any of the "Custom" value fields. For example if I use
[submission:values:myfield:nolabel]as the custom value for my "E-mail subject" field, after I save the form and edit the e-mail again, the default value of the field is truncated to:nolabel]. It looks like this has to do with theme_webform_inline_radio_label() using filter_xss(). Something in that function doesn't like using token values as attributes.Comment #31
quicksketchTo resolve this, I think we can just remove the call to filter_xss() in our label checking. We're using this label in about a dozen places in Webform, but we know every place where this is done and it's never a user-defined value. The default values of the fields displayed inline within the radio button are already individually sanitized. So overall this function call can be removed without harm. This patch removes the filter_xss() call.
Comment #32
quicksketchCommitted to 7.x-4.x.
Comment #34
quicksketchHeh, from #15:
This is exactly what happened (again) in Firefox: #2045871: Inline textfields select radio button in Firefox, preventing entry of custom e-mail settings
We may need to roll this patch back.
Comment #35
hass commentedLet's find a solution without a rollback, please.
Comment #36
quicksketchYeah I think we have something that will work in #2045871: Inline textfields select radio button in Firefox, preventing entry of custom e-mail settings, thanks for joining in the other issue.
Comment #36.0
quicksketcha