DXField
The single-field renderer that powers DXForm and
DXTable’s edit modal. It renders one FieldDefinition of any type — wired to
a useForm instance for value binding, validation state, and error display —
and exposes #value, #span, #info, #info-popover, #hint and
#password-actions slots for per-field customisation.
You will usually reach for DXForm, but DXField is
available directly for one-off fields or custom layouts. It binds via a dot
path (keyPath), so it also works for nested values such as repeater rows
(lines.0.price).
Live Examples
Single Field Renderer
DXField renders one field of any type. DXForm and DXTable use it internally, but you can drop it in directly — here with per-field #hint and #value slot overrides.
Props
| Name Click to sort ascending | Type | Required Click to sort ascending | Default | Description |
|---|---|---|---|---|
field | FieldDefinition | Yes | - | The field definition to render (see DXForm for the full schema). |
form | UseFormReturn<any> | Yes | - | Form instance owning the field's data and errors. |
model | any | No | form.data | Model passed to predicates (label/hint/when/disabled/readonly). |
keyPath | string | No | field.key | Dot path into form.data for the value (e.g. lines.0.price for nested binding). |
errorKey | string | No | keyPath | Error key for validation lookups. |
Slots
| Name Click to sort ascending | Description | Scoped Props |
|---|---|---|
value | Replace the built-in input control with custom markup. Call update(v) to write the value. | - |
span | Full-width custom block (used when the field is marked span: true). | - |
info | Rich info block rendered always-visible below the field (not the label popover). | - |
info-popover | Rich body for the label’s hover/focus info popover (lists, bold, paragraphs). Overrides the plain field.info text. | - |
hint | Override the hint text rendered below the field. | - |
password-actions | Only for type: "password". Extra controls beside the password field, after its input and reveal (eye) toggle — e.g. a Generate button. They wrap below the field when the row is too narrow. setRevealed(true) shows the password exactly as the eye does. See Password actions below. | - |
Display-only and password field options
Two FieldDefinition options change how a control is rendered rather than what
it holds (the full schema lives on the
DXForm page):
| Name Click to sort ascending | Type | Required Click to sort ascending | Default | Description |
|---|---|---|---|---|
plaintext | boolean | (model) => boolean | No | false | Display the value as static text instead of a control — no border, no input box (Bootstrap’s .form-control-plaintext). Implies read-only for every field type: anything backed by a real input (the text family, textarea, currency, percentage, autocomplete) renders as static text, while control types with no native readonly state (select/radio/checkbox/switch/file) are disabled instead. |
revealable | boolean | No | true | Only for type: "password". Shows the reveal (eye) toggle that switches the input between masked and plain text. Set false for a bare password input. |
readonly is unchanged: it still renders a bordered, non-editable control, which
reads as “you could edit this, but can’t”. Use plaintext for values a
profile/settings page shows but never lets you edit.
revealable is on by default, so every password field gets the eye toggle
unless you opt out.
inputProps remains an escape hatch that wins over the field’s own bindings —
inputProps: { readonly: true } works as before — but it cannot override the
guarantees these two options make. A plaintext field cannot be made editable
through it, and the reveal toggle owns the password input’s type, so an
inputProps type cannot unmask a field whose toggle still reads “Show
password”.
A revealed password is also re-masked whenever the field is reseeded with a
different record, which is what DXTable’s edit modal does between rows.
Password actions
The password-actions slot places your own controls beside a password field,
after its input and eye. Its props can write the value
(update) and drive the eye’s state (revealed, setRevealed), so a
“Generate password” button can fill the field and show what it generated
while the input and the eye stay dfl’s own:
<DXField :field="{ key: 'password', type: 'password', label: 'Password' }" :form="form">
<template #password-actions="{ update, setRevealed, disabled }">
<DButton variant="secondary" :disabled="disabled"
@click="update(generatePassword()); setRevealed(true)">
Generate
</DButton>
</template>
</DXField>
- The eye keeps working by itself, and keeps its
aria-label/aria-pressed;setRevealedchanges the same state, so the two always agree. disabledis true when the field is disabled or read-only.- The eye is drawn as part of the input (its border, corners and background).
Your controls are not: they sit after the field with a small gap, as
ordinary buttons. A
secondaryDButtonmatches the form’s other buttons; don’t try to join them to the input. - The controls share the input’s row only while the input keeps at least
--dx-password-input-min-width(11rem by default). In a narrower column (a phone, or a modal with the label beside the field) they wrap onto a line of their own below the input, so a revealed password stays readable. Retune the minimum with the CSS variable (or$dx-password-input-min-widthin Sass). An icon-onlyDButtonneeds anaria-label. - The slot does not render on a
plaintextfield (there is no input). - On a
revealable: falsefield the slot still renders (the input gets the group for it), but there is no eye andsetRevealeddoes nothing: the field never unmasks. - A field without the slot renders exactly as before.
- Slot props are typed as
PasswordActionsSlotProps. InDXFormthe slot ispassword-actions(<key>); inDXTable’s edit/create modal it isedit-password-actions(<key>).
const fields = [
// Static text, no input box.
{ key: 'email', label: 'Email', type: 'text', plaintext: true },
// Editable until the record is verified, then display-only.
{ key: 'vat_number', label: 'VAT number', type: 'text', plaintext: (model) => model.verified },
// A bare password input, without the reveal toggle.
{ key: 'password', label: 'Password', type: 'password', revealable: false },
];
Units beside the input
append puts short unit text in a cell after the input, and prepend one
before it, so the label can stay the name of the thing: “Online notice” with
“minutes” after the box rather than “Online notice (minutes)”. Either may be a
function of the model, like hint.
const fields = [
{ key: 'online_notice', type: 'number', label: 'Online notice', append: 'minutes' },
{ key: 'repeat_every', type: 'number', label: 'Repeat', prepend: 'every',
append: (model) => (model.repeat_every === 1 ? 'week' : 'weeks') },
{ key: 'share', type: 'percentage', label: 'Share', append: '% of takings' },
{ key: 'cost', type: 'currency', label: 'Cost', append: 'per case' },
];
- They apply to
number,text,email,urlandtelfields. On apercentage,appendreplaces the ”%” cell (which stays the default). On acurrency,appendis the unit the price is per,DXCurrencyInput’s ownappend, andprependis not used: the leading cell iscurrencySymbol. Other types ignore both. - The input’s
aria-describedbynames the cells (after any id you pass ininputProps), so a screen reader reads the label as the field’s name and the unit as its description. readonlykeeps the input group.plaintextshows the value followed by its unit as one line of text (“120 minutes”, “every 2 weeks”, “20% of takings”); an empty value shows nothing rather than a unit on its own.- A field with neither option renders exactly as it did before they existed: no input group, no extra markup.
Extended Component
This is a custom component that extends beyond simple Bootstrap Vue Next wrappers, providing additional functionality specific to Laravel dashboards.