Skip to content

Commit

Permalink
feat: add placeBefore to wrapFields()
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed May 11, 2023
1 parent e4df541 commit 906753c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,13 @@ public function sortFormFields(InputfieldWrapper $form, $fields)
*
* @return InputfieldFieldset
*/
public function wrapFields(InputfieldWrapper $form, array $fields, array $fieldset, $placeAfter = null)
{
public function wrapFields(
InputfieldWrapper $form,
array $fields,
array $fieldset,
$placeAfter = null,
$placeBefore = null,
) {
// If we only want to show a single field we exit early
// as we dont need the wrapper in that case. If you still want to show the
// wrapper add &wrapper=1 to your url.
Expand Down Expand Up @@ -575,6 +580,9 @@ public function wrapFields(InputfieldWrapper $form, array $fields, array $fields
if ($placeAfter) {
if (!$placeAfter instanceof Inputfield) $placeAfter = $form->get((string)$placeAfter);
$form->insertAfter($fs, $placeAfter);
} elseif ($placeBefore) {
if (!$placeBefore instanceof Inputfield) $placeBefore = $form->get((string)$placeBefore);
$form->insertBefore($fs, $placeBefore);
} elseif ($last) $form->insertAfter($fs, $last);
else $form->add($fs);

Expand Down

0 comments on commit 906753c

Please sign in to comment.