diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-21 09:35:06 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-21 09:35:06 +0100 |
| commit | c3608912295032da3733e41d04a4dc5ee49b3cc8 (patch) | |
| tree | 7630342b259f7c73c650973e17ef8468c94de6a1 | |
| parent | df3841bcb4dc82103d3fca46a4257446680bb51a (diff) | |
| download | stock-c3608912295032da3733e41d04a4dc5ee49b3cc8.tar.gz stock-c3608912295032da3733e41d04a4dc5ee49b3cc8.tar.bz2 stock-c3608912295032da3733e41d04a4dc5ee49b3cc8.zip | |
Fix hide_kitlocker filter not persisting when unchecked
Unchecked checkboxes send nothing in the GET request, so the default-on
guard reset the filter every time. Add a hidden sentinel field so PHP can
distinguish a fresh page load (apply default) from a form submission with
the box deliberately unchecked.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | list_components.php | 4 | ||||
| -rw-r--r-- | templates/list_components.tpl | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/list_components.php b/list_components.php index 751cdcf..9bb68ac 100644 --- a/list_components.php +++ b/list_components.php @@ -22,8 +22,8 @@ if( !empty( $_REQUEST['find'] ) ) { $_REQUEST['search'] = $_REQUEST['find']; } -// Default on — hide pure kitlocker components; show those also supplied by kitlocker to elves -if( !isset( $_REQUEST['hide_kitlocker'] ) ) { +// Default on unless the filter form has been submitted (sentinel field present) +if( !isset( $_REQUEST['hide_kitlocker'] ) && empty( $_REQUEST['filter_submitted'] ) ) { $_REQUEST['hide_kitlocker'] = 1; } diff --git a/templates/list_components.tpl b/templates/list_components.tpl index f27d3b3..d9f6e76 100644 --- a/templates/list_components.tpl +++ b/templates/list_components.tpl @@ -6,6 +6,7 @@ <a href="{$smarty.const.STOCK_PKG_URL}edit_component.php">{biticon ipackage="icons" iname="kt-add-filters" iexplain="Create Component"}</a> {/if} <form class="minifind" action="{$smarty.const.STOCK_PKG_URL}list_components.php" method="get"> + <input type="hidden" name="filter_submitted" value="1" /> <div class="form-inline"> <div class="form-group"> <input class="form-control input-sm" type="text" name="find" placeholder="{tr}Components{/tr}" value="{$smarty.request.find|escape}" /> |
