How to hide one field

Is there any way to hide one particular field?

[original thread by Tanya Gamarian]

Hi @ohtanya, you can provide your own ui schema and just don’t include a control for the specific field. Let’s say this is your JSON schema:

{
  type: 'object',
  properties: {
    name: {
      type: 'string',
      minLength: 3,
    },
    vegetarian: {
      type: 'boolean'
    },
    birthDate: {
      type: 'string',
      format: 'date',
    },
  }
}

You could then use the following ui schema to “hide” the birthDate field by not specifying a Control for it.

{
  type: 'HorizontalLayout',
  elements: [
    {
      type: 'Control',
      scope: '#/properties/name'
    },
    {
      type: 'Control',
      scope: '#/properties/vegetarian'
    }
  ]
}

Dears,
What about the need to have a hidden field (by default) that gets displayed based on some rule?

Hi @maltrkawi, you can take a look at our SHOW/HIDE rules.

What condition can I set to HIDE always?

I found the solution.

    "rule": {
        "effect": "HIDE",
        "condition": {}
     }
1 Like