diff --git a/CHANGELOG.md b/CHANGELOG.md index 91629566d..2154a8a6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - `cargo install sqlpage`, and any build from the crates.io tarball, no longer needs internet access. The browser libraries now come from npm and ship inside the published crate. Building from a git checkout needs `npm ci` first. Pre-built binaries and the Docker image are unaffected. - The browser libraries are now part of the browser scripts. SQLPage no longer defines the `window.tabler` and `window.bootstrap` globals; custom scripts that reached for them should load their own copy of Bootstrap. - The startup message now reports the address the server actually bound instead of the one it was configured with. +- Inside a form component you can now use the `prefix`, `prefix_icon` and `suffix` row-level parameters when `type` is `select`. ## v0.46.3 diff --git a/examples/official-site/sqlpage/migrations/01_documentation.sql b/examples/official-site/sqlpage/migrations/01_documentation.sql index 460c82093..7766adbbf 100644 --- a/examples/official-site/sqlpage/migrations/01_documentation.sql +++ b/examples/official-site/sqlpage/migrations/01_documentation.sql @@ -386,6 +386,7 @@ In SQLite, the query would look like SELECT ''select'' as type, ''Select a fruit...'' as empty_option, + ''cherry'' as prefix_icon, json_group_array(json_object( ''label'', name, ''value'', id diff --git a/sqlpage/templates/form.handlebars b/sqlpage/templates/form.handlebars index a8851b867..22b02ddd6 100644 --- a/sqlpage/templates/form.handlebars +++ b/sqlpage/templates/form.handlebars @@ -87,26 +87,30 @@ {{~#if value includeZero=true}}{{value}}{{/if~}} {{~else~}}{{#if (eq type 'select')~}} - +
+ {{#if prefix_icon}}{{icon_img prefix_icon}}{{/if}} + {{#if prefix}}{{prefix}}{{/if}} + + {{#if suffix}}{{suffix}}{{/if}} +
{{else}}
{{#if prefix_icon}}{{icon_img prefix_icon}}{{/if}} diff --git a/tests/sql_test_files/component_rendering/form_select_uses_prefix.sql b/tests/sql_test_files/component_rendering/form_select_uses_prefix.sql new file mode 100644 index 000000000..d90d09352 --- /dev/null +++ b/tests/sql_test_files/component_rendering/form_select_uses_prefix.sql @@ -0,0 +1,4 @@ +select 'form' as component; +select 'select' as type, + 'It works !' as prefix, + '[{"label": "Orange", "value": 0}, {"label": "Apple", "value": 1}, {"label": "Banana", "value": 3}]' as options;