Feature: #109366 - Hide form fields with no selectable items
See forge#109366
Description
Relational fields in the FormEngine, such as type=select with
foreign_, type=category, and type=select, with
misconfigured empty items are now automatically handled when no selectable
items are available. Also, type=language fields are hidden if
only a single language is configured, since a dropdown with one choice serves
no purpose.
For regular users, the field is removed entirely. When backend debug mode is
enabled (
$GLOBALS), the field
is kept as read-only with an info badge so admins can identify configuration
issues such as missing records or restrictive TSconfig.
Common scenarios where this applies:
- A
categoriesfield is displayed but nosys_records exist.category - A select field references
fe_, but no frontend user groups have been created.groups - All available items have been removed via TSconfig
removeorItems keepconfiguration.Items - The backend user has no permissions for any of the available items.
- A site has only one configured language.
- A
type=selectfield is misconfigured and has no items.
Affected field types
type=select(all render types includingselect): hidden when no items are available. For fields withTree foreign_, static items like "Hide at login" are not counted - they only make sense when actual foreign records exist.table type=category: hidden when no items are availabletype=language: hidden when only one language is available (the special-1"All languages" item is not counted as a meaningful choice)
Existing values
Fields not rendered in the form are simply not submitted on save. The DataHandler preserves the existing database value for non-submitted fields, so no data is lost when a field is hidden by this feature.
Opt-out
The behavior can be disabled per field using the TCA configuration option
show:
$GLOBALS['TCA']['tt_content']['columns']['categories']['config']['showIfEmpty'] = true;
Impact
Fields without selectable items are now hidden by default. In backend debug
mode, the fields are shown as read-only with an info badge.
Extensions that rely on empty fields always being shown should set
show to true in their TCA configuration.