jester icon indicating copy to clipboard operation
jester copied to clipboard

checkbox is not added to request.params when checkbox is not checked initially

Open some-avail opened this issue 1 year ago • 2 comments

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.

some-avail avatar Aug 06 '24 11:08 some-avail

Or is there some way to iterate thru the @-values?

some-avail avatar Aug 06 '24 11:08 some-avail

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 = ""

some-avail avatar Aug 08 '24 00:08 some-avail