- Issue created by @fhelms
- π§πͺBelgium dieterholvoet Brussels
I just tested this module again and it does seem to work. What can be confusing is that the red asterisk is always present, but when saving no validation error will show if the user doesn't have one of the configured roles. Could you test again and actually try to save the entity?
- π§πͺBelgium dieterholvoet Brussels
The changes in π Only show red asterisk when the field is actually required Active should remove this limitation. Could you test them and let me know if it works for you?
- π©πͺGermany fhelms
thank you @dieterholvoet for looking into this.
unfortunately it is not just about the red asterix.
field validation will have this field required by all roles in my (pretty vanilla) install of D10.5.2 - π©πͺGermany fhelms
on thing I just noticed is that I went
> composer require 'drupal/required_by_role:^2.0'
only and composer installed 'required_by_role' AND 'required_api' but 'required_api' is not mentioned in the composer json?
both modules are present in the contrib module folder though - π§πͺBelgium dieterholvoet Brussels
I'm sorry, but I can't reproduce. I just tested on a fresh Drupal 11.2.3 installation with required_api 3.0.0 and required_by_role 2.0.0 and everything is working as it should.
It seems that when I select "Required by role" in the "Choose a required strategy" section the "default required" field is selected automatically? Hard to tell. My problems persist.
The default 'Required' checkbox shouldn't be visible when you have selected the 'Required by role' strategy. It should look like this:
Are you sure the default 'Required' checkbox is visible while the 'Required by role' strategy is selected?
- π§πͺBelgium dieterholvoet Brussels
Just tested on a Drupal 10.5.1 site, works as well. Do you have any errors logged after changing the field settings? Did you run database updates after updating the module?
- πΊπΈUnited States drupgirl
This module is not working on my end.
core: ^10.5
required_by_role:^2.0'Install this module and set a few fields to be set by the module and select a couple roles that will be restricted.
Try saving a node without providing required field data as a role that does not have the restriction.
Node does not save, as the fields are required for ALL user roles. - πΊπΈUnited States drupgirl
Updated title because my issue was on a fresh install of required_by_role:^2.0.
- π§πͺBelgium dieterholvoet Brussels
Okay, I was able to reproduce the issue, but only on simple fields that have HTML5 required validation through the
required
attribute. Before I was testing on more complex fields like entity reference and paragraphs fields. The good news is that the patch from π Only show red asterisk when the field is actually required Active seems to fix the issue. Please test this and let me know if it works for you, so I can merge the fix and make a release. Don't forget to clear caches after applying the patch. - π©πͺGermany fhelms
Yes, the changes in #3540426 fixed the problem for me.
Thank you for fixing it so promptly. - πΊπΈUnited States BenStallings
I am also having this problem after upgrade. The patch from #3540426 hides the red asterixes appropriately, but the fields are still required to submit the form when they should not be.
Here's another clue that might help: If I edit the field, I see that the required strategy is set to Required by Role and everything looks good. But if I click the Core strategy, it shows the field is required. (This agrees with the config file: in v1.3 it was
required: false
but now it isrequired: true
.) If I uncheck the required box and save while the Core strategy is still selected, that change gets saved. But if I switch back to the Required by Role strategy, the Core required box gets checked again immediately and gets saved withrequired: true
.If I manually change the config file to say
required: false
and import, the change either does not import or does not stay changed. Exporting config results inrequired: true
. - π§πͺBelgium dieterholvoet Brussels
@benstallings what's the field type you tested with?
- πΊπΈUnited States BenStallings
@dieterholvoet it occurred with the body field, a plain text field, and a list field.
- π§πͺBelgium dieterholvoet Brussels
@benstallings sorry, but can't reproduce this with the patch from π Only show red asterisk when the field is actually required Active applied. required is also set to true in my case, but that shouldn't matter.
third_party_settings: required_api: required_plugin: required_by_role required_plugin_options: - editor required: true