Making a field required does not set the right attributes. Looks like a core bug.

Comments

axel.rutz created an issue. See original summary.

geek-merlin’s picture

Status: Active » Needs review
StatusFileSize
new1.35 KB

Patch flying in.

  • axel.rutz committed 836d70a on 8.x-1.x
    Issue #2983462 by axel.rutz: Fix required-handling
    
geek-merlin’s picture

Status: Needs review » Fixed

Tested and used in production, so committing.

Status: Fixed » Closed (fixed)

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

gintass’s picture

If I understand correctly this development version already has a patch: 8.x-1.0-alpha4+7-dev (2018-Jul-10)
I tested with the reference field that becomes visible AND required based on another fields value. The field is a reference to a taxonomy vocabulary with view terms. The terms are being displayed as selectable radio buttons in the reference field.
The field becomes required, when condition is fulfilled, but the "required" indicator (red star) is being displayed next to each option instead of a label. Also when I try to save the node with one of the options selected I get the error:
"The website encountered an unexpected error. Please try again later."

In another test I set the field to "required" in the field configuration and made it invisible if control field is not checked. In this case it worked. I was able to create the node without selecting any values in the required field wasn't visible on the form. If this was your goal, so I guess you can consider that this patch works, but if you wanted to allow to set the "required" based on a condition, then this doesn't work, at least in case of a reference field with the list of options)

geek-merlin’s picture

Status: Closed (fixed) » Needs work

OK thanks for reporting this back! So i have reverted the patch (it's in beta5 but not in current dev) and setting NW.