When a user adds a link field to a Content type with following field configuration,
field config

With this settings, while creating a content node. Field renders with no form-required style.
Fields appears as follows;

field on content type

This should, with the settings above, look like
desired output

Please suggest the way to do this.

Comments

rahul.shinde’s picture

Assigned: rahul.shinde » Unassigned
notmike’s picture

StatusFileSize
new10.87 KB

I'm not much of a coder, but I can document. The red asterisk is disabled on line 683 of link.module to avoid a third red asterisk on the parent label if both Title and URL are present. The problem is that if there is no Title, and URL is required. There is no red asterisk at all.

683 $element['#required'] = FALSE; // davereids patch from jan 2011

In my attached screenshot (red-asterisk.png), "Featured Resource Link" is my parent label. Line 683 is set to FALSE for the first two examples, but TRUE for the second two.

red asterisk examples

dqd’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs work » Active

Hm, seems to become a funny WTF issue in repeat and belongs to this issues:
#1038444: Extra required indicator
#1217396: "multiple-value" & "required" breaks input/save and produces error: "At least one title or URL must be entered."

please use needs work status only for issues with included and reviewed but failed patches, which still need to get optimization.

But thanks for the report. ++

dqd’s picture

Title: Missing required sign » Missing red asterisk for required fields
Assigned: Unassigned » dqd

and from the 7.x-1.x-dev point of view you rather refer to this line (680) I guess:

'#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE, // davereids patch from jan 2011

and this one at 710:

  // To prevent an extra required indicator, disable the required flag on the
  // base element since all the sub-fields are already required if desired.
  $element['#required'] = FALSE; // davereids patch from jan 2011
ASMBL’s picture

Any word if this was included in the dev snapshot of 2012-Mar-01?

dqd’s picture

@ DDO : this needs deeper dipping and a patch. Feel free to try your skills on it ;)

dqd’s picture

Assigned: dqd » Unassigned
ASMBL’s picture

Thanks for the reply. I'll investigate.

wooody’s picture

same problem with dev version. any way to fix it?

dcmouyard’s picture

Issue tags: +Accessibility

This is an accessibility issue. This field should be rendered like required text fields in core.

Here's what markup should look like:

<div class="form-item form-type-link-field ">
  <label for="input-id">Label <span class="form-required" title="This field is required.">*</span></label>
  <div class="link-field-subrow clearfix">
    <div class="link-field-url">
      <div class="form-item form-type-textfield">
        <input type="text" id="input-id" class="form-text required">
      </div>
    </div>
  </div>
</div>
grndlvl’s picture

I checked this a couple of time, but could def. use another eye.

Basically this patch only sets the encapsulating element required attribute to FALSE only when there are multiple elements or a title field. Which, in turn displays the asterisks per the image in comment #2.

I have attached a patch for both 7.x-1.x and 7.x-1.0.

grndlvl’s picture

Status: Active » Needs review
alexanderpas’s picture

Status: Needs review » Reviewed & tested by the community

works perfectly.

jcfiala’s picture

Status: Reviewed & tested by the community » Fixed

I've pushed this into git - will be included in next release (7.x-1.1)

veeraprasadd’s picture

@ #11
Attached patch works fine. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

brightbold’s picture

@grndlvl — Thanks for taking the time to patch 1.0 as well. I just deployed it and it works beautifully.