OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions ACL field to custom field

This topic contains 5 replies, has 2 voices, and was last updated by  William Radi 4 years, 11 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #38441

    William Radi
    Participant

    Hello Oro guys!

    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:

    https://pasteboard.co/I8Bt8Fk.jpg

    how do I make my custom fields disabled too?

    Thanks guys!

    • This topic was modified 4 years, 12 months ago by  William Radi.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #38449

    Andrey Yatsenko
    Moderator

    Looks like you have to hide the field manually when the user has no access. this can be done at the form type or form type extension. Here is an example
    https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/UserBundle/Form/Type/UserType.php#L273-L285

    #38462

    William Radi
    Participant

    That was a good exemple :D

    Thanks, Andrey!

    #38488

    William Radi
    Participant

    Hey, guys!

    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:

    https://pasteboard.co/I9cZtP2.jpg

    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?

    #38500

    Andrey Yatsenko
    Moderator

    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.

    #38505

    William Radi
    Participant

    Ok, understood…
    Thanks a lot, man! I’ll try it! :D

Viewing 5 replies - 1 through 5 (of 5 total)

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

Back to top