2017 © Pedro Peláez
 

craft-plugin incognito-field

PlainText drop-in replacement that can be set to disabled, hidden or readonly.

image

mmikkel/incognito-field

PlainText drop-in replacement that can be set to disabled, hidden or readonly.

  • Saturday, December 9, 2017
  • by mmikkel
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,324 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 99 % Grown

The README.md

Incognito Field plugin for Craft CMS

PlainText drop-in replacement that can be set to disabled, hidden or readonly., (*1)

Requirements

This plugin requires Craft CMS 5.0 or later., (*2)

What is it?

Incognito Field adds a custom fieldType to Craft CMS called Incognito. Incognito fields work exactly like regular PlainText fields, except that they can be configured to be disabled, readonly or hidden for element edit forms., (*3)

A good example use case for Incognito is whenever you need a field that shouldn't be editable via the CP – e.g. if you want to save some data from a feed or external API on your element model., (*4)

Incognito Field works both standalone and inside Matrix blocks., (*5)

Configuring Incognito Field

Create a new field (or convert an existing Plain Text field) as Incognito Field. Select the rendering mode you want in the Mode setting to make the field hidden, readonly, disabled (or a regular, visible and editable PlainText field). Optionally, override the mode in Mode Override which you can find in the advanced field settings., (*6)

Overriding the rendering mode with Twig logic

You can use Twig in the Mode Override setting field to optionally override the rendering mode. A good use case example is to have the field render as an editable PlainText field for admin users, but be hidden, read only or disabled for everyone else., (*7)

Mode Override examples

Render as an editable PlainText field if the element is an unsaved draft:, (*8)

{{ element.getIsUnsavedDraft() ? 'plain' }}

Render as an editable PlainText field for admin users:, (*9)

{{ currentUser.admin ? 'plain' }}

Render as a visible, read-only field for users in a particular user group:, (*10)

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

Render as an editable PlainText field for users that have edit site permissions for a particular site:, (*11)

{% set site = craft.app.sites.getSiteByHandle('germany') %}
{{ currentUser.can('editSite:' ~ site.uid) ? 'plain' }}

Disclaimer

Please report any bugs, feature requests or other issues here., (*12)

The Versions

09/12 2017

dev-master

9999999-dev

PlainText drop-in replacement that can be set to disabled, hidden or readonly.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft incognito field

09/12 2017

1.0.0

1.0.0.0

PlainText drop-in replacement that can be set to disabled, hidden or readonly.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft incognito field