For the Show and Tell post "DB-tables, One snippet to call them all #3 : Benihikō fr fr"
{repeat: for x in seq(1,rep); locals=outputs}
{=catch(output, "Make sure your table ID and name is written in appropriate places and the snippet form is completed") }{note: preview=no}
{urlload: https://data-api.blaze.today/api/database/fields/table/{=table_id}/; done=(res) -> ["Data":(res)]}
{Resulta=lower(fromjson({=Data}))}{liste=[n.name for n in resulta]}{=liste}{endnote}{note}
Final form.
The multiple options always take priority over the single choice mode. But the single choice mode is the default mode where the snippet start.
If you activated the multiple option (by selecting values in the respective {formmenu and/or {dbselect but want to revert back: simply empty your selection !
Table ID : {formtext: name=Table_id; default=22Char ID of your DB table; cols=22} / Table Name: "goes here, cannot be a variable for {dbselect ![]() ![]() | |
Fields | Records |
{if: not {=Multi_Fields}}{formtoggle: name=Multi_Fields; default=no}{endformtoggle} Single choice: {formmenu: values={=liste}; name=onefield; multiple=no} {else}{formtoggle: name=Multi_Fields; default=no} Multiple choices: {formmenu: name=several_fields; multiple=yes; values={=liste}}{endformtoggle}{endif} | {if: not {=Multi_lines}}{formtoggle: name=Multi_lines; default=no}{endformtoggle} One record: {dbselect: SELECT product_name, Color, Origin, Lenght, motto, Price FROM Mock_Data; space=7JxI3mdWKF1JE6iC4hlZGp; menu=yes; name=OneRow; multiple=no} {else}{formtoggle: name=Multi_lines; default=no} Several record: {dbselect: SELECT product_name, Color, Price, Origin, Lenght, motto FROM Mock_Data; space=7JxI3mdWKF1JE6iC4hlZGp; menu=yes; name=MultiRowS; multiple=yes}{endformtoggle}{endif} |
Unique output = {Output=[[r[f] for f in fields] for r in rows]}{=output} | |
Check and verification: Fields={if: count(several_fields)>0}{Fields=several_fields}{else}{Fields={=[ onefield]}}{endif}{=fields} Rows={if: count(multirows)>0}{Rows=multirows}{else}{Rows=[ onerow]}{endif}{=rows} |
{formtext: name=rep; default=1}
{button: rep= rep - 1
; label=Reduce one!}{button: rep= rep + 1
; label=Add one!}
{=map(outputs, y -> y.output)}