On my registration page i have a custom field where anonymous users don't have view and edit permission.

However without seeing this field, upon saving the registration page the user gets a drupal message: ' 'my custom field is required'.

I have found this behaviour only when the field is a boulean type with a single on/off widget.
As soon as i take a different field or make it a radio button/checkbox widget type the user can save the registration page without the message.

Additional info:
I could make the field 'not required' by unchecking the checkbox on the fieldsetting however i need the field to be required on the user-edit page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Leksat’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Needs review
FileSize
1.25 KB

I was able to reproduce this for the file/image fields also.

STR:
On a fresh D7 installation (Standard profile):
1. Create Text (Text field), Boolean (Single on/off checkbox), and Image (Image) fields.
2. For all newly created fields check "Required field" checkbox, and set custom permissions so only admin role has full access and other roles have no access.
3. Go to user/register page as anonymous user, and try to submit the form.
Result:
1. No error message for the Text field. As expected.
2. There are error messages for Boolean and Image fields.

Probably this issue should be addressed to the core queue, because both file_managed_file_validate() and options_field_widget_validate() do not check the #access property before validation.
However, it would be good to handle this case in the field_permissions module.

Attached patch sets #required property to FALSE for all field for elements with #access == FALSE.

I also updated the priority to Major, because this issue makes module unusable in some cases.

  • mariacha1 committed 8c2907d on 7.x-1.x authored by Leksat
    Issue #2203077 by Leksat: boulean field with single on/off widgit stays...
mariacha1’s picture

Status: Needs review » Fixed

Fixed. Thanks!

mariacha1’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)
FileSize
63.42 KB

Seems to still be a problem with image fields in d8, although the checkbox problem looks solved:

required image

mariacha1’s picture

FileSize
75.9 KB
Anybody’s picture

Thank you for fixing this very important issue. Could you please create a new stable D7 release?

I think this is very important for all of us. The dev works great!