Skip to content

Commit

Permalink
Replace the unique subform id via random bytes by just an increasing …
Browse files Browse the repository at this point in the history
…integer in the fields type rendering process.
  • Loading branch information
Rene Pasing committed Aug 31, 2017
1 parent 949d013 commit a26269c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 0 additions & 3 deletions layouts/joomla/form/field/subform/repeatable-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
'.subform-table-sublayout-section .controls { margin-left: 0px }'
);
}

// @TODO
$unique_subform_id = bin2hex(openssl_random_pseudo_bytes(4));
?>

<div class="row-fluid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);

?>

<tr
Expand Down
4 changes: 1 addition & 3 deletions layouts/joomla/form/field/subform/repeatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
}

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

// @TODO
$unique_subform_id = bin2hex(openssl_random_pseudo_bytes(4));
?>

<div class="row-fluid">
Expand All @@ -47,6 +44,7 @@
data-bt-move="a.group-move-<?php echo $unique_subform_id; ?>"
data-repeatable-element="div.subform-repeatable-group-<?php echo $unique_subform_id; ?>"
data-minimum="<?php echo $min; ?>" data-maximum="<?php echo $max; ?>">

<?php if (!empty($buttons['add'])) : ?>
<div class="btn-toolbar">
<div class="btn-group">
Expand Down
6 changes: 6 additions & 0 deletions libraries/joomla/form/fields/subform.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ protected function getInput()
$data['fieldname'] = $this->fieldname;
$data['groupByFieldset'] = $this->groupByFieldset;

// For each rendering process of a subform element, we want to have a
// separate unique subform id present to could distinguish the eventhandlers
// regarding adding/moving/removing rows from nested subforms from their parents.
static $unique_subform_id = 0;
$data['unique_subform_id'] = ('sr-' . $unique_subform_id++);

// Prepare renderer
$renderer = $this->getRenderer($this->layout);

Expand Down

0 comments on commit a26269c

Please sign in to comment.