Customizing the records view¶
The module ships a default view, dns_records, with three displays:
| Display id | Path | Used by |
|---|---|---|
page_records |
/admin/content/dns/records |
The admin "Records" collection page. |
embed_zone |
(none — embed) | The records list inside the zone canonical page. |
default |
(master, not directly displayed) | Holds the shared field/filter/sort defaults. |
Customize at /admin/structure/views/view/dns_records. The page
display drives the admin records collection; the embed display drives
the inline list on the zone canonical (/dns/{zone}).
Default columns¶
The default view renders these columns:
- Zone (link to the zone canonical)
- Prefix
- Type
- TTL
- Value (the merged column described below)
- Operations (edit / delete dropbutton)
Add or remove columns via the Views UI like any other view. The rdata-aware field described further down lets you surface type-specific data that doesn't have a dedicated base field.
The merged "Value" column¶
ip_address and target are mutually exclusive across record types:
A and AAAA records use ip_address; CNAME, MX, NS, PTR, SRV (and
the upcoming DNAME plugin) use target. To avoid two half-empty
columns side-by-side, the shipped view adds both fields and then
merges them into a single visible column via the table style's
"Column" mapping.
The mechanics, in case you want to replicate the pattern for other field combinations:
- Add both fields to the view (
Edit → Add → Field). - Open Settings on the table format (the gear icon next to "Table" in the Format box).
- In the Column dropdown for the second field, pick the column
key of the first. Both fields now render into the same
<td>— for any given row only the populated one shows. - Set the desired column Separator if you want multiple populated fields joined within a cell.
The same pattern works for grouping multiple rdata keys (priority,
weight, port for SRV) into a single "Value" column, joined with a
space or separator.
Rendering rdata values as columns¶
Type-specific data that doesn't fit a shared field — MX/SRV priority,
SRV weight/port, TXT content, CAA flags — lives in the record's
rdata JSON field. To render one of those keys as a column in any
view on the dns_record source:
- Edit the view at
/admin/structure/views/view/dns_records(or create a custom view). - Add → Field, search for Record data value.
- In the field options, set Rdata key to the JSON key you want
to render — e.g.
priority,weight,port,content. - Set the Label for the column (e.g. "Priority").
- Save.
Add multiple instances for multiple keys — one per column.
The handler renders the value as a string. Empty cells mean the record's plugin doesn't use that key (e.g. an A record's "Priority" column will be blank — that's correct, A records don't have a priority).
Limitations of the rdata field handler¶
By design, the handler is render-only:
- No SQL filter — you can't filter records by an rdata key value
via Views' standard filter UI on
2.x. - No SQL sort — column headers aren't query-level sortable. However, the table style's JavaScript click-sort still works on rendered text if you enable "Sortable" on the column.
- No relationship handler — you can't follow an rdata-stored reference (e.g. SRV's target hostname) as if it were an entity reference.
These limitations are deliberate — full filter/sort support on JSON keys requires either DB-engine-specific JSON path queries or a denormalized index, both of which would be heavy-handed for the use cases this handler covers.
The 3.x branch (Drupal 11.4+) will gain real JSON-aware filter and
sort handlers via Connection::jsonCondition(). If you need rich
querying on a particular rdata key today, the right path is
promoting it to a real base field
once it clears the threshold.
Reverting your changes¶
Customizations to the default view are stored in active config. To
revert any display back to the shipped defaults, use Revert
on the view's Manage page, or delete the view's active config and
re-import from config/install:
drush config:import:single --source=modules/contrib/dns/config/install/views.view.dns_records.yml