Skip to content

Commit b39c886

Browse files
committed
updated docs
1 parent be86f17 commit b39c886

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

packages/docs/docs/api-reference/uiSchema.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,25 @@ render(
485485

486486
### emptyValue
487487

488-
The `ui:emptyValue` uiSchema directive provides the default value to use when an input for a field is empty
488+
The `ui:emptyValue` uiSchema directive provides the default value to use when a field is empty. This applies whenever the field is blank, whether from initial render, a form reset, or the user clearing the input.
489+
490+
```tsx
491+
import { RJSFSchema, UiSchema } from '@rjsf/utils';
492+
493+
const schema: RJSFSchema = {
494+
type: 'object',
495+
required: ['name'],
496+
properties: {
497+
name: { type: 'string' },
498+
},
499+
};
500+
501+
const uiSchema: UiSchema = {
502+
name: {
503+
'ui:emptyValue': '',
504+
},
505+
};
506+
```
489507

490508
### enumDisabled
491509

@@ -588,6 +606,28 @@ If you need to enable the default error display of a child in the hierarchy afte
588606

589607
This is useful when you have a custom field or widget that utilizes either the `rawErrors` or the `errorSchema` to manipulate and/or show the error(s) for the field/widget itself.
590608

609+
### initialValue
610+
611+
The `ui:initialValue` uiSchema directive pre-fills a field on initial render and after a form reset. It takes priority over `schema.default` but does not override user-provided `formData`. Useful for hidden fields that need a fixed value.
612+
613+
```tsx
614+
import { RJSFSchema, UiSchema } from '@rjsf/utils';
615+
616+
const schema: RJSFSchema = {
617+
type: 'object',
618+
properties: {
619+
country: { type: 'string' },
620+
},
621+
};
622+
623+
const uiSchema: UiSchema = {
624+
country: {
625+
'ui:initialValue': 'US',
626+
'ui:widget': 'hidden',
627+
},
628+
};
629+
```
630+
591631
### inputType
592632

593633
To change the input type (for example, `tel` or `email`) you can specify the `inputType` in the `ui:options` uiSchema directive.
@@ -682,6 +722,10 @@ The `ui:readonly` uiSchema directive will mark all child widgets from a given fi
682722

683723
> Note: If you're wondering about the difference between a `disabled` field and a `readonly` one: Marking a field as read-only will render it greyed out, but its text value will be selectable. Disabling it will prevent its value to be selected at all.
684724
725+
### required
726+
727+
The `ui:required` uiSchema directive overrides the schema's `required` status for a field. Setting `ui:required` to `true` shows the required indicator and produces a validation error if the field is left empty. Setting it to `false` hides the required indicator, but does not suppress schema-level validation. A `console.warn` is emitted when `ui:required` is `false` on a schema-required field without `ui:initialValue` or `ui:emptyValue` set.
728+
685729
### rows
686730

687731
You can set the initial height of a textarea widget by specifying `rows` option.

0 commit comments

Comments
 (0)