Skip to content

Commit f62b951

Browse files
committed
checked attribute for checkboxes and radio buttons
1 parent 933d416 commit f62b951

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
228228
('required', 'Set this to true to prevent the form contents from being sent if this field is left empty by the user.', 'BOOL', FALSE, TRUE),
229229
('min', 'The minimum value to accept for an input of type number', 'NUMBER', FALSE, TRUE),
230230
('max', 'The minimum value to accept for an input of type number', 'NUMBER', FALSE, TRUE),
231+
('checked', 'Used only for checkboxes. Indicates whether the checkbox should appear as already checked.', 'BOOL', FALSE, TRUE),
231232
('step', 'The increment of values in an input of type number. Set to 1 to allow only integers.', 'NUMBER', FALSE, TRUE),
232233
('description', 'A helper text to display near the input field.', 'TEXT', FALSE, TRUE),
233234
('pattern', 'A regular expression that the value must match. For instance, [0-9]{3} will only accept 3 digits.', 'TEXT', FALSE, TRUE),
@@ -303,7 +304,7 @@ In this example, depending on what the user clicks, the target `index.sql` page
303304
304305
', json('[{"component":"form", "method": "GET", "action": "index.sql"}, '||
305306
'{"name": "fruit", "type": "radio", "value": 1, "description": "An apple a day keeps the doctor away", "label": "Apple"}, '||
306-
'{"name": "fruit", "type": "radio", "value": 2, "description": "Oranges are a good source of vitamin C", "label": "Orange"}, '||
307+
'{"name": "fruit", "type": "radio", "value": 2, "description": "Oranges are a good source of vitamin C", "label": "Orange", "checked": true}, '||
307308
'{"name": "fruit", "type": "radio", "value": 3, "description": "Bananas are a good source of potassium", "label": "Banana"}'||
308309
']'));
309310

sqlpage/templates/form.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{#if (or (eq type "radio") (eq type "checkbox"))}}
88
<div class="form-selectgroup form-selectgroup-boxes d-flex flex-column my-1">
99
<label class="form-selectgroup-item flex-fill">
10-
<input type="{{type}}" name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} class="form-selectgroup-input">
10+
<input type="{{type}}" name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} {{#if checked}}checked{{/if}} class="form-selectgroup-input">
1111
<div class="form-selectgroup-label d-flex align-items-center p-3">
1212
<div class="me-3">
1313
<span class="form-selectgroup-check"></span>

0 commit comments

Comments
 (0)