Skip to content

Commit

Permalink
[J4] Adds support for custom class on subforms via xml (#35577)
Browse files Browse the repository at this point in the history
* [J4] Adds support for custom class on subforms via xml

* [J4] Adds support for custom class on subforms via xml
  • Loading branch information
regularlabs committed Sep 19, 2021
1 parent 7e49a2f commit 86d021c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion layouts/joomla/form/field/subform/repeatable-table.php
Expand Up @@ -28,6 +28,7 @@
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var string $class Classes for the container
* @var array $buttons Array of the buttons that will be rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s fieldset
*/
Expand All @@ -39,6 +40,8 @@
->useScript('webcomponent.field-subform');
}

$class = $class ? ' ' . $class : '';

// Build heading
$table_head = '';

Expand Down Expand Up @@ -80,7 +83,7 @@
?>

<div class="subform-repeatable-wrapper subform-table-layout subform-table-sublayout-<?php echo $sublayout; ?>">
<joomla-field-subform class="subform-repeatable" name="<?php echo $name; ?>"
<joomla-field-subform class="subform-repeatable<?php echo $class; ?>" name="<?php echo $name; ?>"
button-add=".group-add" button-remove=".group-remove" button-move="<?php echo empty($buttons['move']) ? '' : '.group-move' ?>"
repeatable-element=".subform-repeatable-group"
rows-container="tbody.subform-repeatable-container" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
Expand Down
5 changes: 4 additions & 1 deletion layouts/joomla/form/field/subform/repeatable.php
Expand Up @@ -28,6 +28,7 @@
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var string $class Classes for the container
* @var array $buttons Array of the buttons that will be rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s fieldset
*/
Expand All @@ -39,11 +40,13 @@
->useScript('webcomponent.field-subform');
}

$class = $class ? ' ' . $class : '';

$sublayout = empty($groupByFieldset) ? 'section' : 'section-byfieldsets';
?>

<div class="subform-repeatable-wrapper subform-layout">
<joomla-field-subform class="subform-repeatable" name="<?php echo $name; ?>"
<joomla-field-subform class="subform-repeatable<?php echo $class; ?>" name="<?php echo $name; ?>"
button-add=".group-add" button-remove=".group-remove" button-move="<?php echo empty($buttons['move']) ? '' : '.group-move' ?>"
repeatable-element=".subform-repeatable-group" minimum="<?php echo $min; ?>" maximum="<?php echo $max; ?>">
<?php if (!empty($buttons['add'])) : ?>
Expand Down

0 comments on commit 86d021c

Please sign in to comment.