Cms: [Feature Request] Add a Read-only feature to fields

Created on 4 Mar 2019  Ā·  11Comments  Ā·  Source: craftcms/cms

Description

I think Craft would be more awesome and more handsome if it allowed me to mark some fields as read-only. just a small checkbox in the field's settings 😽

content modeling enhancement

Most helpful comment

AWW @brandonkelly u guys are the best >.<

All 11 comments

There’s a plugin for it https://plugins.craftcms.com/incognito-field

@Sam-Black-0013 Is that plugin relatively similar to what you’re looking for?

Yub it is, thanks. But can't it be added as a core feature in fields ?

@Sam-Black-0013 Just making sure we’re on the same page. There are lots of similar enhancements planned for Craft 4.0 so I will make a note of this for that.

AWW @brandonkelly u guys are the best >.<

I would find it handy if there could be readonly setting on fields by user roles. Like if admins/devs could edit the field from the CMS without changing the field type from readonly to editable, but it would always be readonly for everyone else.

Craft 3.5 has a new field layout designer, which includes the ability to add additional UI elements, including one that pulls in a site template of your choosing. So you can use that to put whatever arbitrary HTML you want in your field layout, which I’d say resolves this.

Brandon, I think you misunderstood the feature request. The idea is to be able to configure regular fields’ visibility on edit pages. Ideally this would work with every field type, and configuration would be per field layout.

The Incognito field plugin solves this for plain text fields only. Visibility can be configured dynamically using Twig.

{{ currentUser.isInGroup('editors') ? 'readonly' : 'hidden' }}

https://github.com/mmikkel/IncognitoField-Craft3#overriding-the-rendering-mode-with-twig-logic

There hasn’t been any mention of toggling field _visibility_ here, just _writability_. Toggling field visibility based on user groups is covered by #947.

I interpreted the issue as requesting a _field-level_ ā€œRead-onlyā€ checkbox – not something that could sometimes be writable, sometimes not, depending on a condition. At which point, it would be better to just not have a field in the first place, and use a Template UI element in the field layout. But can reopen if I was mistaken.

Ah ok, that’s how you read it! I don’t see the purpose of a field that’s not writeable at all, so I assumed the issue is about its rendering in the control panel. Content would be written to it in other ways, from front end forms, or programatically.

947 is pretty much covering my intepretetion of this request.

I don’t see the purpose of a field that’s not writeable at all

Yeah good point. I’ll go ahead and reopen on the assumption that the request is for _sometimes_-read-only fields.

Was this page helpful?
0 / 5 - 0 ratings