Skip to content
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

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

Open
some-avail opened this issue Aug 6, 2024 · 2 comments

Comments

@some-avail
Copy link

some-avail commented Aug 6, 2024

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
Copy link
Author

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

@some-avail
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant