如何将 (Joomla) 子表单的管理布局从 table 模式更改为 div 模式?

How to change (Joomla) admin layout of subforms from table mode to div mode?

我需要将 Joomla 3.9.13(后端)中子表单的管理 table 视图更改为(已经存在的)div 模式。 我可以通过更改代码来做到这一点:

plugins/fields/repeatable/repeatable.php 第 52 行

变化中:

$fieldNode->setAttribute('layout', 'joomla.form.field.subform.repeatable-table');

收件人:

$fieldNode->setAttribute('layout', 'joomla.form.field.subform.repeatable');

这是一个核心修改。那么如何在不修改核心文件的情况下实现这一目标呢?

子表单字段类型有一个默认功能,允许您select 布局。

layout (optional) the name of the layout to use when displaying subform fields. Available layouts:

joomla.form.field.subform.default render the subform in a div container, without support of repeating. Default for single mode.

joomla.form.field.subform.repeatable render the subform in a div container, used for multiple mode. Support groupByFieldset.

joomla.form.field.subform.repeatable-table render the subform as a table, used for multiple mode. Supports groupByFieldset. By default each field is rendered as a table column, but if groupByFieldset=true then each fieldset is rendered as a table column.

您需要以 xml 文件形式更新此文件,该文件可在 /models/forms/viewname.xml

中找到
<field
    name="field-name"
    type="subform"
    label="Subform Field"
    layout="joomla.form.field.subform.repeatable"
/>

https://docs.joomla.org/Subform_form_field_type

正如@Lodder 所建议的,您可以使用 repeatable 布局中的代码覆盖 repeatable-table 布局。它对您不起作用的原因是因为您覆盖了前端模板中的文件而不是后端模板。

如果您将覆盖放在:

/administrator/templates/isis/html/layouts/joomla/field/subform

它们应该按预期工作(我假设 Isis 是您的默认后端模板)。