Skip to content

HowToDisableFields

Carlo Barazzetta edited this page Jan 20, 2017 · 1 revision

How to selectively disable editing for a single field

Generally, Kitto hides all fields that have IsVisible: False (at either the model or view level) and displays all fields that have IsReadOnly: True (again, at either the model or view level) as read-only (non editable).

What if I want to keep a field editable while inserting a new record and read-only while editing an existing record? The classic example is when a model has a user-entered primary key, which we want the user to specify when creating a record but which we don't want to be modified afterwards.

In this case, you can use the CanInsert and CanUpdate boolean properties at the model or view level. In our example we will have:

Fields:
  Id:
    # CanInsert is True by default - unless it's an expression field.
    CanUpdate: False

Please note that you can't make editable a field that logically isn't, such as an expression field.


We do not recommend using user-visible primary key. We generally prefer to generate our keys and never display them to the user.


Clone this wiki locally