PHPackages                             fastbolt/sonata-admin-protected-fields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. fastbolt/sonata-admin-protected-fields

ActiveLibrary[Admin Panels](/categories/admin)

fastbolt/sonata-admin-protected-fields
======================================

Provides simple functionality for protecting fields in sonata admin

v0.1.1(3y ago)0224[1 issues](https://github.com/fastbolt/sonata-admin-protected-fields/issues)MITPHPPHP ^8.0

Since Aug 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fastbolt/sonata-admin-protected-fields)[ Packagist](https://packagist.org/packages/fastbolt/sonata-admin-protected-fields)[ Docs](https://github.com/fastbolt/sonata-admin-protected-fields)[ RSS](/packages/fastbolt-sonata-admin-protected-fields/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (3)Used By (0)

[![Composer version](https://camo.githubusercontent.com/6b29fafbd71625425e9cefcf3ad98b8b9d28405ba30bcdee67e67ec85ff20bcf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c6473)](https://packagist.org/packages/fastbolt/sonata-admin-protected-fields)

[![Code Climate maintainability](https://camo.githubusercontent.com/5ee5d62030392dadfd0868addbf765dfb482e9ff845769575b81e0695c13d436/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c6473)](https://codeclimate.com/github/fastbolt/sonata-admin-protected-fields)[![Test Coverage](https://camo.githubusercontent.com/55414ab43995b14a0dcef5bb455bad7818f40a70900f1a490d61df7acfde8f90/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c6473)](https://app.codecov.io/gh/fastbolt/sonata-admin-protected-fields/)

[![Type Coverage](https://camo.githubusercontent.com/c6ff00e7d4075ebf6c1ea809a0af217589cf5a9c6fa590c31ae9c96d7ef23ab8/68747470733a2f2f73686570686572642e6465762f6769746875622f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c64732f636f7665726167652e737667)](https://shepherd.dev/github/fastbolt/sonata-admin-protected-fields)[![Psalm Level](https://camo.githubusercontent.com/6865b70dbc7c0d76959e21a5c6272ef7d94dd494e04894dce5da1d4dbb087bfe/68747470733a2f2f73686570686572642e6465762f6769746875622f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c64732f6c6576656c2e737667)](https://shepherd.dev/github/fastbolt/sonata-admin-protected-fields)

[![GitHub](https://camo.githubusercontent.com/3996d0bd377a2f130fcadc98f68a5e00ed16a4dda8cd6ee7763077dece1c8b9a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f66617374626f6c742f736f6e6174612d61646d696e2d70726f7465637465642d6669656c64732f504850556e697425323074657374732f6d61696e3f6c6162656c3d5465737473)](https://github.com/fastbolt/sonata-admin-protected-fields/actions)

Field and Entity protection for sonata admin
============================================

[](#field-and-entity-protection-for-sonata-admin)

This library aims to provide an easy way to protect fields from being edited in sonata admin, while still being displayed in the form.

Using the library, some entities fields may be fixed, e.g. coming from the ERP or some other system, while other fields may still be edited by the user. Furthermore, items created in the GUI might still be editable, including all fields, which are not editable for other instances.

In addition, the same checks can be used to protect entities from being deleted in the Sonata admin GUI on a per-item basis.

The system relies on the `Fastbolt\SonataAdminProtectedFields\Protection\Checker\Checker` interface which has access to all entity properties.

For custom implementation, please head to the [Implementing custom checkers](#implementing-custom-checkers) section.

Prerequisites
-------------

[](#prerequisites)

Due to the PHP Attribute usage, we need at least PHP 8.0 or higher.

For now, the bundle is tested using PHP 8.0, 8.1 and 8.2 and the [sonata admin bundle](https://github.com/sonata-project/SonataAdminBundle) version 4.9

Installation
------------

[](#installation)

The library can be installed via composer:

```
composer require fastbolt/sonata-admin-protected-fields

```

Configuration
-------------

[](#configuration)

If not configured automatically, the bundle needs to be enabled in your project's `bundles.php` file:

```
