Updated: Comment #5
Instructions to reproduce the problem
- Enable date_repeat_field module.
- Create a date field to a content type.
- Add something to the "Help text" field in the field creation form.
- Set the "Repeating date" to "No".
- Check that help text is shown on the node create/edit form for the date field.
- Set the date field's "Repeating date" to "Yes".
- Check the node create/edit form. Now the help text is missing.
Diagnosis
Drupal's core field module handles multivalue fields differently than single value fields. Help text is not positioned after every field instance but below the set of fields. Date repeat field is a multivalue field. For multivalue fields the help text (description) is removed and printed separately. The problem seems to be that date_repeat_field module does not use the function theme_field_multiple_value_form to render the field set and doesn't render it. Below is the relevant code.
Drupal 7.26 - /modules/field/field.form.inc
function field_multiple_value_form
Line 218: '#description' => $multiple ? '' : $description,
Removes the help text from single field instances.
function theme_field_multiple_value_form
Line 350: $output .= $element['#description'] ? '
' : '';
Adds help text below multivalue fields. This function is not used by date_repeat_field.
See also:
- Repositioning help texts on theme layer - https://drupal.org/node/1347866
- Repositioning help texts on module layer - https://drupal.org/project/label_help
Proposed resolution
Let's find out where the date repeat field is rendered and add the description tag there. Positioning it at the top would probably be best.
Remaining tasks
Find out where the date repeat field is rendered.Add the help text element (description) to date repeat field.
User interface changes
- Help text is displayed also with the repeat option on.
API changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | date-n2186191-34.patch | 2.47 KB | welly |
| #30 | date-n2186191-30.patch | 2.48 KB | damienmckenna |
Comments
Comment #1
vijaycs85Thanks for reporting @jiv_e. I can reproduce the issue and at first look I thought might be introduced by #1691342: field description is displayed multiple times. But it is not. However I couldn't really get the bottom of it.
Comment #2
jiv_e commentedWorking on it.
Comment #3
jiv_e commentedUpdated the issue summary.
Comment #4
jiv_e commentedFixed typos.
Comment #5
jiv_e commentedHere's a patch. It does the following:
Comment #6
jiv_e commentedMarking as needs review.
Comment #7
vijaycs85Thanks for working on this. @jiv_e. Here is some code level comments. Will have a manual check and would be great to have some tests to cover this cases.
not sure, why can't we keep the field_description here?
Unset is to avoid duplicate of them, which doesn't looks like covered in this patch anymore
Again, why not fieldset_description?
Comment #8
jiv_e commentedHappy to help!
I admit that this fix is wider than the original issue, but this fixes the issue and in my opinion unifies the date_combo fields interface and makes the UX better. Otherwise we would have help text at the top of the fieldset for fields with repeat on and bottom of the fieldset for start-end fields only.
Comment #9
vijaycs85Comment #10
marc.groth commentedThanks @jiv_e for the patch. From a functionality perspective it works perfectly. I re-rolled it against 7.x-2.8 to test locally without any issues. Good job :)
Marking it as 'Reviewed & tested by the community' as it's been a year and nobody has said it's a problem.
Comment #11
jiv_e commentedThanks! :)
Comment #12
pmackay commentedWould it be possible to get this rolled into a release?
Comment #13
podarokthis needs tests coverage
Comment #14
kaarePatch didn't apply, so re-rolled with minor coding style fixes.
Comment #15
kaareComment #16
jastraat commentedThe patch in #14 worked for our purposes.
Comment #17
streever commentedIt looks like this is fixed & working; can I post here to get an auto notification when the issue is 'resolved' and it's rolled out?
thanks (and apologies if I've done something wrong...!)
Comment #18
jiv_e commented@podarok, can you describe what things should our tests cover?
Comment #19
jiv_e commentedComment #20
PascalAnimateur commentedUsing patch #14 doesn't work with localize_fields.
Here's a simpler patch that does work in my case, but removes the extra text added regarding the start / end components.
Comment #21
merilainen commentedPatch in #20 applied, but didn't help me. I modified the patch in #14 and removed the t() which is not required for field strings, I think they are automatically running through t() anyway. Now it works and I can translate the string normally from Drupal UI.
Comment #22
lussolucaRerolled #5 on top of the new 2.9 release
Comment #23
WorldFallz commentedThis also fixes an issue where the help text doesn't display when the "Render as a regular field" option is used on a non-repeating date field.
Comment #24
paulwdru commentedVery funny, after applying patch #22, if I tick Render as a Regular Field, both field label and help text can be translated under Node & Entityform but Profile2 shows Untranslated Label with Translated Help Text.
How come only Label is NOT translated in Profile2 ? I'd never encountered situation like this.
Any ideas ? Thanks
Comment #25
paulwdru commentedHi,
Referring to #24, I traced out the cause of why label wasn't translated in Profile2 when using Date-Popup widget.
Could someone create a patch for date/date_popup/date_popup.module at line 326 as follows ?
Original
Changed To
I'm not familiar with creating a patch and just manually modified the codes.
Thanks
Comment #26
Anonymous (not verified) commented#22 fixes the missing help problem when displaying as a regular text field
Comment #27
Anonymous (not verified) commentedComment #28
autopoietic commentedI can confirm that #22 fixes the issue I was experiencing whereby a standard single value date field (in my case on a user profile) was not displaying the configured help text.
Comment #29
zerolab commentedNitpicking here, but we need to stick to the d.o. coding standards
Space after
ifSpace after
//.thegoes past the 80 char limit.Comment #30
damienmckennaFixes for the minor coding standards mistakes.
Comment #31
zerolab commentedLGTM
Comment #32
damienmckennaComment #33
idebr commentedThe t-function is not necessary: this function should never be used to translate variables. Translating the field description can be be done with i18n_field.
Comment #34
welly commentedUpdated the patch based on feedback above. Can confirm this is working as expected. Can we get this merged?
Comment #35
damienmckennaWhile you shouldn't mark your own patch as RTBC, the patch looks good and the only change is removal of the t() function.
Comment #36
welly commentedApologies, I thought I'd selected Needs Review! Must have mis-clicked.
Comment #38
vijaycs85Only unanswered item is #25 which doesn't look like related to this issue @paulwdru, please check the issue queue for related issue and if not found, create a new issue for the title translation issue you are facing.