I have some custom required fields added to Oro Account. I’d like to make these fields editable just for who has access to do it, but the default Oro behavior (disable the field) doesn’t work in my fields.
Oro blocks the user, but doesn’t let to save to form. This error appear:
Andrey’ solution worked well, but another field is not ok. Account field work_speciality must be required but not all users can update it when updating an Account.
If I just try to take it out of the form type if access is not granted, another error appear to me when a unauthorized user tries to update the account:
So, how do I make it work? In other words, if access is not granted, don’t show the field if the user is updating an account, but if access is granted, the field be required?
The issue appears because you have required validation constraint (Assert) for the work_speciality field.
The first option is removing the constraint. Then the field will be not required for all the users.
The second solution is to use validation groups to make the constraint work only when the form is submitted by the user with access to the field, then the field will be required for that user, but not required for users who can’t edit it. See https://symfony.com/doc/3.4/validation/groups.html for more details.
We collect cookie information with a goal to provide you with the best user experience. By using this website, you agree to our use of cookies. Read Oro Inc.’s Cookie policy.
We collect cookie information with a goal to provide you with the best user experience. By using this website, you agree to our use of cookies. Read Oro Inc.’s Cookie policy.