checkbox is not added to request.params when checkbox is not checked initially
When I iterate thru request.params in the post-phase, I find that initially unchecked checkboxes are not added to request.params. (that is boxes without the checked-attribute).
However, the unchecked checkboxes values can be accessed thru @"somecheckbox" without returning a key-error.
Should the code not be adjusted to add the keys for unchecked checkbox with the value empty-string?
For refactoring my code i need to use request.params. Can this feature be added?
Thanks.
Or is there some way to iterate thru the @-values?
Workaround to extract the code from the routes do the following in the post-route:
# read in the vars from request.params into control-table cta
var cta = initTable[string, string]()
for key, value in request.params:
cta[$key] = $value
and call the control-value thru a separate function like:
proc vlu*(controlta: var Table[string, string]; keyst: string): string =
#[
Safe lookup of control-value vlu based on control-key keyst
Look up and return a value in the table and if the key is missing return an empty string
]#
try:
result = controlta[keyst]
except:
result = ""