DXField

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.

Price
£
The list price before tax.
Online notice
minutes
append puts the unit after the input; plaintext shows "120 minutes".
Allergens
Celery
Cereals containing gluten
Crustaceans
Eggs
The model is an array of the on rows' values.
Plan Currently selected: pro
Branch Pick a suggestion or type your own: main
Password
The reveal toggle is on by default — set revealable: false for a bare input.
New password
Generate fills the field and reveals it; the eye still hides it again.
Usernameplaintext renders the value as static text rather than a control you cannot use.
Rating

Props

Name Click to sort ascendingType Required Click to sort ascendingDefault Description
fieldFieldDefinitionYes-The field definition to render (see DXForm for the full schema).
formUseFormReturn<any>Yes-Form instance owning the field's data and errors.
modelanyNoform.dataModel passed to predicates (label/hint/when/disabled/readonly).
keyPathstringNofield.keyDot path into form.data for the value (e.g. lines.0.price for nested binding).
errorKeystringNokeyPathError key for validation lookups.

Slots

Name Click to sort ascendingDescription Scoped Props
valueReplace the built-in input control with custom markup. Call update(v) to write the value.-
spanFull-width custom block (used when the field is marked span: true).-
infoRich info block rendered always-visible below the field (not the label popover).-
info-popoverRich body for the label’s hover/focus info popover (lists, bold, paragraphs). Overrides the plain field.info text.-
hintOverride the hint text rendered below the field.-
password-actionsOnly 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 ascendingType Required Click to sort ascendingDefault Description
plaintextboolean | (model) => booleanNofalseDisplay 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.
revealablebooleanNotrueOnly 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; setRevealed changes the same state, so the two always agree.
  • disabled is 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 secondary DButton matches 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-width in Sass). An icon-only DButton needs an aria-label.
  • The slot does not render on a plaintext field (there is no input).
  • On a revealable: false field the slot still renders (the input gets the group for it), but there is no eye and setRevealed does nothing: the field never unmasks.
  • A field without the slot renders exactly as before.
  • Slot props are typed as PasswordActionsSlotProps. In DXForm the slot is password-actions(<key>); in DXTable’s edit/create modal it is edit-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, url and tel fields. On a percentage, append replaces the ”%” cell (which stays the default). On a currency, append is the unit the price is per, DXCurrencyInput’s own append, and prepend is not used: the leading cell is currencySymbol. Other types ignore both.
  • The input’s aria-describedby names the cells (after any id you pass in inputProps), so a screen reader reads the label as the field’s name and the unit as its description.
  • readonly keeps the input group. plaintext shows 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.