From 77fa33730a6e21937f6430cd0ad1cc7b50d00064 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 14:48:08 +0200 Subject: [PATCH] InlineFormView: combine fields and buttons into one 'controls' array --- controllers/ManageAssets.php | 2 +- controllers/ManageErrors.php | 2 +- controllers/ManageTags.php | 2 +- controllers/ManageUsers.php | 2 +- templates/InlineFormView.php | 21 +++++++-------------- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/controllers/ManageAssets.php b/controllers/ManageAssets.php index 59895ff..1d73200 100644 --- a/controllers/ManageAssets.php +++ b/controllers/ManageAssets.php @@ -25,7 +25,7 @@ class ManageAssets extends HTMLController 'method' => 'post', 'class' => 'col-md-6 text-end', 'is_embed' => true, - 'buttons' => [ + 'controls' => [ 'deleteChecked' => [ 'type' => 'submit', 'caption' => 'Delete checked', diff --git a/controllers/ManageErrors.php b/controllers/ManageErrors.php index 75186aa..b8f608c 100644 --- a/controllers/ManageErrors.php +++ b/controllers/ManageErrors.php @@ -30,7 +30,7 @@ class ManageErrors extends HTMLController 'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'method' => 'post', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'clear' => [ 'type' => 'submit', 'caption' => 'Delete all', diff --git a/controllers/ManageTags.php b/controllers/ManageTags.php index 9dc653b..6f79df7 100644 --- a/controllers/ManageTags.php +++ b/controllers/ManageTags.php @@ -21,7 +21,7 @@ class ManageTags extends HTMLController 'action' => BASEURL . '/edittag/', 'method' => 'get', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'add' => [ 'type' => 'submit', 'caption' => 'Add new tag', diff --git a/controllers/ManageUsers.php b/controllers/ManageUsers.php index 9e80cb9..a8c35ee 100644 --- a/controllers/ManageUsers.php +++ b/controllers/ManageUsers.php @@ -21,7 +21,7 @@ class ManageUsers extends HTMLController 'action' => BASEURL . '/edituser/', 'method' => 'get', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'add' => [ 'type' => 'submit', 'caption' => 'Add new user', diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php index c6f1736..779146e 100644 --- a/templates/InlineFormView.php +++ b/templates/InlineFormView.php @@ -21,26 +21,19 @@ class InlineFormView echo '
'; - if (!empty($form['fields'])) + foreach ($form['controls'] as $name => $control) { - foreach ($form['fields'] as $name => $field) - { - if ($field['type'] === 'select') - self::renderSelectBox($field, $name); - else - self::renderInputBox($field, $name); - } + if ($control['type'] === 'select') + self::renderSelectBox($control, $name); + elseif ($control['type'] === 'submit') + self::renderSubmitButton($control, $name); + else + self::renderInputBox($control, $name); } echo ' '; - if (!empty($form['buttons'])) - foreach ($form['buttons'] as $name => $button) - { - self::renderSubmitButton($button, $name); - } - if (!empty($form['is_group'])) echo '
';