Skip to content

Commit 3a03b92

Browse files
theochr72Theo CochereauThéo Cochereau
authored
feature/add_markdown_to_forms (#809)
add description_md to the form component --------- Co-authored-by: Theo Cochereau <[email protected]> Co-authored-by: Théo Cochereau <[email protected]>
1 parent b892a72 commit 3a03b92

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
293293
('create_new', 'In a multiselect with a dropdown, this option allows the user to enter new values, that are not in the list of options.', 'BOOLEAN', FALSE, TRUE),
294294
('step', 'The increment of values in an input of type number. Set to 1 to allow only integers.', 'REAL', FALSE, TRUE),
295295
('description', 'A helper text to display near the input field.', 'TEXT', FALSE, TRUE),
296+
('description_md', 'A helper text to display near the input field - formatted using markdown.', 'TEXT', FALSE, TRUE),
296297
('pattern', 'A regular expression that the value must match. For instance, [0-9]{3} will only accept 3 digits.', 'TEXT', FALSE, TRUE),
297298
('autofocus', 'Automatically focus the field when the page is loaded', 'BOOLEAN', FALSE, TRUE),
298299
('width', 'Width of the form field, between 1 and 12.', 'INTEGER', FALSE, TRUE),
@@ -339,7 +340,7 @@ When loading the page, the value for `:username` will be `NULL` if no value has
339340
'{"name": "Last name", "required": true, "description": "We need your last name for legal purposes."},'||
340341
'{"name": "Resume", "type": "textarea"},'||
341342
'{"name": "Birth date", "type": "date", "max": "2010-01-01", "value": "1994-04-16"},'||
342-
'{"name": "Password", "type": "password", "pattern": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$", "required": true, "description": "Minimum eight characters, at least one letter and one number."},'||
343+
'{"name": "Password", "type": "password", "pattern": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$", "required": true, "description_md": "**Password Requirements:** Minimum **8 characters**, at least **one letter** & **one number**. *Tip:* Use a passphrase for better security!"},'||
343344
'{"label": "I accept the terms and conditions", "name": "terms", "type": "checkbox", "required": true}'||
344345
']')),
345346
('form','Create prepended and appended inputs to make your forms easier to use.',

sqlpage/templates/form.handlebars

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
{{#if description}}
3232
<small class="form-hint mt-0">{{description}}</small>
3333
{{/if}}
34+
{{#if description_md}}
35+
<small class="form-hint mt-0">{{markdown description_md}}</small>
36+
{{/if}}
3437
</div>
3538
</div>
3639
</label>
@@ -123,6 +126,9 @@
123126
{{#if description}}
124127
<small class="form-hint mt-0">{{description}}</small>
125128
{{/if}}
129+
{{#if description_md}}
130+
<small class="form-hint mt-0">{{markdown description_md}}</small>
131+
{{/if}}
126132
</label>
127133
{{/if}}
128134
{{/if}}

0 commit comments

Comments
 (0)