WidgetReadOnly
Overview
Renders a field value as non-editable text, with optional prefix and suffix strings. When app and model props are provided, the raw foreign-key value is resolved to a human-readable name and rendered as a link to the related record's detail view.
Theme entry: WidgetReadOnly
Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| name | String | undefined | The widget name; falls back to the field context value when omitted. | |
| label | String | undefined | The label displayed next to the widget; falls back to the field context value when omitted. | |
| help | String | undefined | Help text displayed alongside the widget; falls back to the field context value when omitted. | |
| readOnly | Boolean | false | Whether the widget is read-only; falls back to the field context value when omitted. | |
| required | Boolean | undefined, // let the default from field context take over | Whether the widget is required; falls back to the field context value when undefined. | |
| modelValue | String|Number|Boolean|Array|Object | undefined | The widget's bound value (v-model); used only in contextless mode. | |
| fieldToWidget | Object|Function | null | Adapter that converts the form model value into a value suitable for the widget UI. | |
| widgetToField | Object|Function | null | Adapter that converts the widget UI value back into a form model value for validation and submission. | |
| invalid | Boolean | undefined | Manually set the invalid state when not in a field context. | |
| warning | Boolean | undefined | Manually set the warning state when not in a field context. | |
| disabled | Boolean | false | Whether the widget is disabled. | |
| disabledFn | Function | null | A function that returns whether the widget should be disabled; takes precedence over the disabled prop. | |
| contextless | Boolean | false | When true, the widget ignores any surrounding field or form context and manages its own state. | |
| displayDependencies | Array | () => [] | Field paths whose values the widget needs for display logic; registered with the field context. | |
| themeOverride | String|Object|Array | null | A partial theme object merged with the component's default theme; accepts a class string, class array, or theme object. | |
| app | string | undefined | Django app label used to resolve the foreign-key value to a display name and link. | |
| model | string | undefined | Django model name used to resolve the foreign-key value to a display name and link. | |
| foreignKeyObj | object | undefined | Pre-fetched related object; used instead of a lookup when already available. | |
| loading | boolean | false | When true, shows a loading indicator instead of the resolved value. | |
| prefix | string | "" | Static text prepended to the displayed value. | |
| suffix | string | "" | Static text appended to the displayed value. | |
| options | array|boolean | false | Static choice options used to resolve stored values to display labels. | |
| optionLabel | string | "label" | Key on each option object used as the displayed label. | |
| optionValue | string | "value" | Key on each option object used as the stored value. |
Slots
default
Scoped slot.
Bindings
| Name | Description |
|---|---|
| raw-value | |
| value |
Events
| Name | Description |
|---|---|
update:modelValue | Emitted when the widget value changes. |
Source
client/lib/widgets/WidgetReadOnly.vue