If a conditional field is required and the user doesn't type anything in and submits, the title prints back with the asterisk appended to it in the error message.

CommentFileSizeAuthor
#4 fix_required_display.patch2.3 KBthreexk

Comments

bsuttis’s picture

Title: Requierd conditional field puts asterisk in error message » Required conditional field puts asterisk in error message

Title typo =/

threexk’s picture

I started to look into this, and it appears the '*' was intentionally put in the wrong place because there was no simple way to put it in the right place. (Required conditional fields are not actually set to required when they are given to Drupal to render, yet Drupal normally inserts the asterisk depending on whether the field is set to required.)

peterpoe’s picture

@threexk: Correct. The asterisk is put there by theme_form_element in forms.inc
I didn't want to override just to move the asterisk. Now that conditional fields are passed through a custom theme function (theme_conditional_fields_form_item), I guess that we could work there...

threexk’s picture

Status: Active » Needs review
StatusFileSize
new2.3 KB

Here's a patch using theme_conditional_fields_form_item() per your suggestion, peterpoe. It sets #required for all fields with #required_field just prior to drupal_render(). That way, Drupal renders them like it would any other required field.

I don't think you'd ever want required conditional fields to look different than a normal required field, so I removed theme_conditional_field_required_title(). (This was mainly duplicated code from core anyway.)

peterpoe’s picture

Tested and seems to work fine... Adding to cvs.

peterpoe’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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