We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to use Acl to a specific field of object?

I want to apply access control entry to a specific field of an object. Any one have any idea about how to do that with \Phalcon\Acl ? Thank you

edited May '16

What you mean as to a specific field of object ? To check if user can edit specific field or what ?



1.2k

Yes. For example, i want the ID only to be viewable by an administrator, but not by others.

What you mean ? In view ? Or when selecting from database ? Or after selecting remove this field ? I don't quite understand what you want to achieve.



1.2k

Sorry for the mistake and not clear. I mean i want to program to set and manage permission on the each row in the table. For example, some rows in a table no one can update except the admin.

Okay. Using phalcon 2.1.x there is ability to add function in acl and use acl pretty much on objects with custom user defined function.

By mistake it's already in documentation for 2.0.x https://docs.phalcon.io/en/latest/reference/acl.html#function-based-access read about it here and check if it's sufficient for you.