Closed (won't fix)
Project:
Drupal core
Version:
5.x-dev
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
13 Sep 2006 at 02:18 UTC
Updated:
8 Jul 2015 at 20:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
drummAnd here is a patch.
Comment #2
webchickExcellent. I like this very much. However, the string 'required' is not translatable.
Comment #3
drummRight. Adding t().
Comment #4
RobRoy commentedIs this preferred over including markup at the top or bottom of the form saying "* denotes that a field is required." or something to that effect? Might be implications of stretching out forms too much or be too overwhelming having a bunch of red "required"s instead of one small red character. I'm not a big fan of the look of the "required" after the colon as well.
I would prefer including a legend at the top or bottom explaining the star, but always injecting that markup at the top might be a bit trickier for forms with markup already at the top.
Comment #5
oadaeh commentedThe "required" looks pretty clean, but it seems to me that it should be in parentheses.
Comment #6
drummBoth keeping the * and adding a key and spelling out required are accepted methods. I'm not aware of any research comparing the two.
The choice is adding it to every field or adding it to the top and/or bottom of the form.
As stated in the original post- in my opinion, direct labels are better than a key because
1. No need to hunt for what a * means. Web pages are not read linearly top to bottom, so we can't assume the key will be seen before a *.
2. No need to remember what a * means. Everyone has to figure out what the * means at some point and probably remember it if they fill out enough forms.
On parenthesis- I concentrated on using color and size to make the label visually distinct and simple. Parenthesis can certainly be added by contributed themes. They can be in core if we can decide that most sites would want them.
Comment #7
webchickI decided to do some Googling tonight to get to the bottom of the question of which is better.
Here's what I found:
Just Add Water recommends grouping all required fields together in a "required" fieldset, but failing that indicating required fields with an asterisk. In addition, the article points out to several prominent sites (Yahoo!, Washington Post, etc.) that use red asterisks to indicate required fields.
Forms That Work says not to use asterisks to denote fields that are optional, even when there are far more required fields than optional, because the standard convention is that they mark required fields.
A List Apart doesn't provide a preference on how to indicate required fields, but notes that they should not be in red because red normally indicates an error condition. I noticed you coloured yours maroon, so you probably read a similar article. :)
Then as a personal thing, I find it easier to scan '*' than I do "required" because my eye can't stop reading it each and every time, even though I already know what it's going to say. :P
So I'm now leaning towards keeping the *, but providing a legend. Working on a patch now...
Comment #8
webchickOk, no I'm not. I am way too tired. ;)
But basically, what needs to happen is as the form's being built, it needs to register if there are one or more required fields. If so, on form render, show the message, "* indicates a required field."
chx threw some preliminary code in a pastebin: http://drupal.pastecode.com/4692 but in my state of sleepiness I can't figure out what else to do with it. :P Hopefully someone else can have better luck. ;)
Comment #9
andremolnar commented+1
I try to point out in the report that items like these are ultimately controlled by the theme developer and the recomendation to include the word 'required' should be a system default.
If people just want an asterisk - well that's up to them - afterall - its their site... But out of the box Drupal should consider '('. t('required') . ')'
andre
Comment #10
edmund.kwok commentedHow about this? Patch sets a global variable, $required_legend and it is set to TRUE in theme_form_element if the element has the #required attribute. Then theme_form will check if $required_legend it TRUE showing the legend. Of course using something other than drupal_set_message would be better.
Or it's not a good way to get this done?
Comment #11
drummdrupal_set_message() is wrong. A '* is required' key belongs as normal text right next to the form. For example, try out your patch with the login block showing.
Leaving as for review since there is a perfectly fine patch at #3.
Comment #12
drummAnother review of #10- We have a whole form array with all sorts of stuff in it, $required_legend should be part of that array and not another global variable.
Comment #13
Jaza commented-1 to changing the current system. I like my little red asterisks just the way they are.
As webchick's research points out (#7), the asterisk is a well-recognised symbol for denoting required fields. It's also much more elegant and visually pleasing than using the word 'required' all over a form.
By the way, in this case I disagree with ALA's warning against using red: no user is going to jump up and down in alarm, when they see one tiny character marked in red (especially when they already know what that character represents).
If you're really concerned about accessibility, then I found an interesting article that lists a number of strategies for implementing accessible required fields, and our current 'asterisk strategy' is one of them (and the proposed new strategy is listed as well). Another article about required form fields by Derek Featherstone (well-known accessibility guru) suggests that the asterisk is one of the best strategies, and it goes into some detail on how to best implement the asterisk for required fields.
If it ain't broke, don't fix it. And besides, this can all be customised at the theme level, if people really want to change it.
Comment #14
Freso commentedJust a couple of internationalisation related notes:
t()function as well, as other locales might or might not be accustomed to another character/sign/thing which means "this is required".t('required')is bad, as "required" can have different translations depending on context. Please, please, please use more verbose strings than this! (Yes, I realise this also includes the "*" above. Signs shouldn't have more than one meaning anyway, but they might have anyway, depending on context.)Comment #15
andremolnar commentedI guess this is turning into bike shed colour debate.
Positions have been stated, the patches have been made - its now up to the powers that be to make a choice without further debate.
andre
Comment #16
drummHere is an alternative patch.
The first required field has '* (required)'
The * are correctly placed in abbr tags instead of span, with a title saying what it is.
Comment #17
drummComment #18
coreb commented(Moving x.y.z version to a real version number)
I'm not sure, but it looks like this issue still fits the criteria to make it into 5.x-dev branch. Although I could just as easily see it as a feature request.
I'm just moving this out of x.y.z version. Someone else put it in the correct place.
Comment #19
dries commentedI don't like the mixed approach (star + legend). Either we continue using stars, or we use required everywhere. Personally, I don't think this is a big problem. Lots of websites use a red star to denote a required field. Maybe we should simply make it so that it reads 'required' when you hover of the star.
Comment #20
Freso commentedI'm undecided on whether to stay with the "hovering", or if there should be a legend as well, however, I'd like to see
$required = '<span class="form-required">'.t('<abbr title="This field is required.">*</abbr>').'</span>';instead of$required = '<abbr class="form-required" title="'. t('This field is required.') .'">'. t('*') .'</abbr>';, as "*" without context could be many, many things (is it a warning? wildcard? star? plain, generic asterisk?). Some locales might also want to separate "This field is required." hover thing from "This field is required." error message. (Can't recall if that string actually exists, or if it's only "%s field is required." though...)Comment #21
Paul Natsuo Kishimoto commented8082 and 9136 are relevant.
Comment #22
drummComment #23
drummComment #24
liam morland