-
Notifications
You must be signed in to change notification settings - Fork 138
Missing in the documentation: How to preset multiple default values on "select" form fields? #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello and welcome to SQLPage ! The "orange and banana" example has its code right above it: select
'form' as component,
'examples/show_variables.sql' as action;
select
'Fruits' as label,
'fruits[]' as name,
'select' as type,
TRUE as multiple,
TRUE as create_new,
'Good fruits...' as placeholder,
TRUE as searchable,
'press ctrl to select multiple values' as description,
'[{"label": "Orange", "value": 0, "selected": true}, {"label": "Apple", "value": 1}, {"label": "Banana", "value": 3, "selected": true}]' as options; The
I think the one you are looking for is Do you think we should present it like this in the example on the website ? Or in the short documentation for Or do you think it's the behavior that is unintuitive, and sqlpage should accept setting default selected values through the Your feedback is welcome ! |
Hello! Thanks for taking the time to reply to this — I now realize — rather stupid question. I would say that the issue turns out to be a mixture of a slight un-intuitiveness (most other fields use a "value" parameter, and this too is how the user-selected values are read from the widget), and — mostly — a combination of my glasses not being strong enough (a true statement) and just plain dumb overlooking from my part. This is good enough as an answer for me, and I would certainly not label this a documentation issue anymore. However, if you are still looking for my input on how this could possibly be improved, I would suggest that the list of default selected items be settable through both the "options" and the "value" parameters, as each approach is better suited in different situations. I would not tag this as urgent, though :P Thanks again, and keep up the good work. A most useful piece of software, indeed. |
Hi, -- formulaire pour insérer tag
SELECT
'form' as component,
'Mettre à jour' as validate,
'upload_image_tag.sql?id='||$id as action,
'orange' as validate_color;
SELECT 'tag[]' as name, 'Tags' as label, 6 as width, 'select' as type, TRUE as multiple, TRUE as dropdown, TRUE as create_new,
'Les tags connus sont déjà sélectionnés.' as description,
json_group_array(json_object(
'label', tag_image,
'value', tag_image,
'selected', tag.image_id=$id
)) as options
FROM tag
Left Join image on tag.image_id=image.id
AND tag.image_id=$id; |
How to preset multiple default values on form fields that allow it seems neither clear nor trivial.
For instance, the reference page for the "Form" component (https://sql.datapage.app/component.sql?component=form), under the title "Example 5", shows a "select" field with two preset values ("Orange" and "Banana"), but no indication is provided as to how this can be achieved.
I personally tried setting the "value" parameter of "select" form fields to a JSON array, a JSON object with "value" keys, an SQL array, an SQL set, as well as multiple individual "value" parameters, and none of those formats have given the expected result.
Could the code sample of that example be completed with the inclusion of the "value" parameter? This would be of great help!
Please and thank you!
The text was updated successfully, but these errors were encountered: