-
Hello, we're looking for a way to ad a null value in a select field in a form. We succeded in doing this way : SELECT
'interpret' AS label,
'tfait_interpret' AS name,
'select' as type,
'[' || group_concat(json_object("label", val_thes, "value", val_thes), ', ') || ', null]' as options FROM ... but, it seems that we don't get a null value, but an empty one. I red that group_concat is not always trustfull... Is it possible to add a null value using :
thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hello ! SELECT
'My dropdown list' as name,
'select' as type,
json_group_array(json_object("label", my_title, "value", id)) as options
FROM (
SELECT id, my_title FROM my_table
UNION ALL
SELECT NULL, 'None of the above'
); Here is an example: https://replit.com/@pimaj62145/SQLPage-dropdown-populated-from-database-example?v=1#index.sql |
Beta Was this translation helpful? Give feedback.
-
About |
Beta Was this translation helpful? Give feedback.
-
thanks a lot for your answer. |
Beta Was this translation helpful? Give feedback.
About
NULL
getting transformed to the empty string (''
): standard web forms can only send string values back to the server, and SQLPage is fully transparent, it doesn't try to decode form values to non-string types.You can easily convert the empty string to a NULL in your sql statement that handles the form results with
NULLIF($your_field, '')