Skip to content

Commit 75d7c46

Browse files
olivierauverlotOlivier Auverlot
authored andcommitted
A unique identifier for the input, which can then be used to select and manage the field with Javascript code. (#250)
Co-authored-by: Olivier Auverlot <[email protected]>
1 parent 8dbd8bd commit 75d7c46

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
237237
('class', 'A CSS class to apply to the form element.', 'TEXT', FALSE, TRUE),
238238
('prefix_icon','Icon to display on the left side of the input field, on the same line.','ICON',FALSE,TRUE),
239239
('prefix','Text to display on the left side of the input field, on the same line.','TEXT',FALSE,TRUE),
240-
('suffix','Short text to display after th input, on the same line. Useful to add units or a currency symbol to an input.','TEXT',FALSE,TRUE)
240+
('suffix','Short text to display after th input, on the same line. Useful to add units or a currency symbol to an input.','TEXT',FALSE,TRUE),
241+
('id','A unique identifier for the input, which can then be used to select and manage the field with Javascript code. Usefull for advanced using as setting client side event listeners, interactive control of input field (disabled, visibility, read only, e.g.) and AJAX requests.','TEXT',FALSE,TRUE)
241242
) x;
242243
INSERT INTO example(component, description, properties) VALUES
243244
(

sqlpage/templates/form.handlebars

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{{#if (or (eq type "radio") (eq type "checkbox"))}}
1717
<div class="form-selectgroup form-selectgroup-boxes d-flex flex-column my-1 col-md-{{default width 12}}">
1818
<label class="form-selectgroup-item flex-fill">
19-
<input type="{{type}}" name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} {{#if checked}}checked{{/if}} class="form-selectgroup-input">
19+
<input type="{{type}}" {{#if id}}id="{{id}}" {{/if}}name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} {{#if checked}}checked{{/if}} class="form-selectgroup-input">
2020
<div class="form-selectgroup-label d-flex align-items-center p-3">
2121
<div class="me-3">
2222
<span class="form-selectgroup-check"></span>
@@ -35,7 +35,7 @@
3535
</div>
3636
{{else}}
3737
{{~#if (eq type "hidden")}}
38-
<input type="hidden" name="{{name}}" value="{{value}}">
38+
<input type="hidden" name="{{name}}" {{#if id}}id="{{id}}" {{/if}}value="{{value}}">
3939
{{else}}
4040
<label class="form-label mb-2 col-md-{{default width 12}}">
4141
{{default label name}}
@@ -48,7 +48,8 @@
4848
class="form-control"
4949
placeholder="{{placeholder}}"
5050
rows="{{default rows 3}}"
51-
{{#if value}}value="{{value}}" {{/if~}}
51+
{{#if id}}id="{{id}}" {{/if~}}
52+
{{~#if value}}value="{{value}}" {{/if~}}
5253
{{~#if minlength}}minlength="{{minlength}}" {{/if~}}
5354
{{~#if maxlength}}maxlength="{{maxlength}}" {{/if~}}
5455
{{~#if required}}required="required" {{/if~}}
@@ -58,6 +59,7 @@
5859
</textarea>
5960
{{else}}{{#if (eq type 'select')}}
6061
<select name="{{name}}" class="form-select"
62+
{{~#if id}} id="{{id}}" {{/if~}}
6163
{{~#if required}} required="required" {{/if~}}
6264
{{~#if autofocus}} autofocus {{/if~}}
6365
{{~#if multiple}} multiple {{/if~}}
@@ -71,6 +73,7 @@
7173
{{#if prefix_icon}}<span class="input-group-text">{{icon_img prefix_icon}}</span>{{/if}}
7274
{{#if prefix}}<span class="input-group-text">{{prefix}}</span>{{/if}}
7375
<input name="{{name}}" class="form-control {{class}}"
76+
{{~#if id}} id="{{id}}" {{/if~}}
7477
{{~#if type}} type="{{type}}" {{/if~}}
7578
{{~#if placeholder}} placeholder="{{placeholder}}" {{/if~}}
7679
{{~#if value}} value="{{value}}" {{/if~}}

0 commit comments

Comments
 (0)