Download & Extend

Fix appearance of marker for required date fields

Project:Date
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

Not sure if this is being worked on at the moment, but the date widget required marker is looking rather funky in the latest dev (see attached screen shot). Right now it’s just floating up in the top left corner, it should really be displayed next to a label.

AttachmentSizeStatusTest resultOperations
Screen shot 2011-08-14 at 2.35.48 AM.png27.09 KBIgnoredNoneNone

Comments

#1

The labels were removed in #1233612: Add a checkbox so user can choose to show/hide the end date. I think that leaving them gone might be ok as long as we can implement #1248720: In-Line 'End Date' with 'to' text.. We should really find a new place for the required markers though.

#2

Maybe the best solution would be to add the marker next to the "Date" label, since that is technically the only component that is required to be filled.

AttachmentSizeStatusTest resultOperations
date_required_marker.png5.22 KBIgnoredNoneNone

#3

The required marker is problematic because we can have such a multitude of date sub-parts and the system error processing can interfere with what the date module is trying to do. I've tried handling this in different ways over the years, with mixed results. Plus not all sub-parts are required, even within dates that are required.

#4

Sub.

#5

Each use case needs to be defined and then the correct 'required' options be made available & labeled accordingly.

One simple use case that could be solved quickly: when the time field is not displayed and the date field is required, the main element's label should have the 'required' indicator. It may also be useful to remove the extra fieldset that gets added for this use case, but that's a separate issue.

#6

If this helps anyone, I needed the required asterisk to appear on the fieldset legend, so hacked it via a bit of code in a custom module:

<?php
/**
* Implements hook_form_alter()
*/
function CUSTOMMODULENAME_form_form_alter(&$form, &$form_state, $form_id) {
  if(
$form_id == 'ID_OF_FORM_HERE') {
   
$form['ID_OF_FIELD_HERE']['und'][0]['#title'] .= '<span title="This field is required." class="form-required">*</span>';
  }
}
?>

#7

Attached is a patch that will add the red marker (form-required span) to the fieldset title in theme_date_combo.

AttachmentSizeStatusTest resultOperations
add-required-marker-1248786-7.patch451 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 5,237 pass(es).View details | Re-test

#8

The patch at #7 works perfectly for me.

#9

Status:active» needs review

The patch fixes the appearance of the marker indeed! Thank you. Do we need more review?

I'm still experiencing a possibly related issue: http://drupal.org/node/301538: Date field does not use #required to mark required date fields.

#10

Status:needs review» needs work

Does not work for me: the patch does add a required star to the fieldset legend (as expected) but does not remove the other star for me.

This can be fixed using CSS but ideally the other star should be removed...

#11

Status:needs work» needs review

patch in #7 works perfectly for me too.

guillaumev, can you provide steps to reproduce your issue on a clean install?

#12

Attached is a patch that removes the floating marker and adds it to the label.

AttachmentSizeStatusTest resultOperations
add-required-marker-1248786-12.patch1.1 KBIdlePASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).View details | Re-test

#13

#12 works great for me against 7.x-2.6+0-dev

#14

Can I ask why is the 'from' label/title is hidden/empty?

Kenneth's patch makes it not just empty but hides it completely.

In case of having starting and ending dates, I think label is quite essential for both.

Thanks,
David

#15

It works for me over 7.x-2.6. Thanks.

#16

Applied patch in #12. Works as desired to make a required day-month-year date with select lists display the required marker.

#17

Placing the marker in the fieldset is considerable usability problem.

Since there are limitations for a systematic fix until now (#3), is there any possible hardcoded solution similar to #6 but applied to a the field label (rather than its fieldset) of a single date field ?

Thanks!

#18

Status:needs review» reviewed & tested by the community

#12 works, thanks!

nobody click here