Hidden and read-only fields
Use hidden to keep a field out of the Studio, and readOnly to show it without letting editors change it. Both are plain booleans on the attribute and apply to every record and every user.
{
name: 'legacyId',
label: 'Legacy ID',
scope: 'global',
dataType: 'string',
inputType: 'text',
hidden: true,
}
{
name: 'sku',
label: 'SKU',
scope: 'global',
dataType: 'string',
inputType: 'text',
unique: true,
readOnly: true,
}What each flag affects
- A hidden or read-only field cannot block save: its
validationrules are not run by the form. - Both flags are Studio behaviour. The attribute still exists in the generated GraphQL API, so imports, agents and API clients can read and write it. Use permission spaces when a value must be unreadable or unwritable for some users.
- Neither flag is
entity.menu.hidden, which hides the whole entity from the sidebar while keeping it in the schema.
Mention the reason in options.comment when a read-only field might surprise editors — for example, that the SKU is
assigned by the ERP and synced by an automation.
Prerequisites
- A Flexkit schema you can edit. See Schemas for an introduction to entities and attributes.
Migrating from callbacks
Earlier versions of flexkit.config.tsx accepted a function for hidden and readOnly:
// No longer supported
hidden: ({ record }) => !record.onSale,
readOnly: ({ currentUser }) => currentUser?.role !== 'owner',The config is now data that is deployed and read back by the Studio, so there is nowhere for that function to run. flexkit deploy refuses a config that still contains one ("hidden" must be a boolean). Move each rule to the layer that owns it:
- Role- or team-based rules (
currentUser.role,currentUser.spaces): declare permission spaces and bind the attribute withspaces: ['finance']. Members of the space see and edit the value; everyone else does not see it at all. Roles still decide who can write. - Record-based visibility (
record.onSale,record.status === 'published'): put the related attributes in a field group such as a Sale or Publishing tab, so editors reach them deliberately rather than conditionally. Keep anoptions.commentthat explains when the field applies. - Record-based locking (lock the price once published): enforce it where writes happen. An automation can reject or revert a change, and a skill can teach agents the rule. Mark the field
readOnly: trueif editors should never change it in the Studio. - Pure visual tidying (hide a field until a sibling is filled): drop the rule, or hide the field with
hidden: trueif it is not meant for editors.
Related
Last updated on