Automatically inserting a const value inside a textbox

Hello,

I have a question regarding the use of the “const” property in the schema. I am providing objects in my schema like this:

{
“type”: “string”,
“const”: “M1”
}

In my application it does look like this then:

Screenshot 2023-12-17 211947

Is there a way to automatically insert the value inside the field and make it readOnly?

Thank you very much.

Best regards,
Philip

Hi @pbarth,

We don’t trigger any data changes just by rendering the form. For automatic data insertion I can recommend the useDefaults mechanism of AJV, see here for the documentation.

To mark the field read only you can specify that either in the JSON Schema or UI Schema, see here for the docs.