passing a hashref in a form? #2313
|
Me again. So my application boils down to a user uploading a zip archive, displaying details of the contents, optionally making changes and saving to a new file. I have the display part working by passing a hashref to the template, but when it comes to saving edits, I am having trouble passing that hashref in the edit form. I tried passing it as a hidden field, but that doesn't seem to work. I suppose I could generate hidden fields for every key in the hash, but I'm guessing there's a better way to do it? |
Replies: 2 comments 7 replies
|
If you're just using regular old It does come with downsides: you really can only edit a one level hash with regular browser input forms. On the plus side, you can use |
|
JSON is just a string, so if you encode the hashref to JSON, you can pass it as a string value into a template or through a form. If you don't need the form to do anything with individual values this seems easiest. (Use from_json/to_json not encode_json/decode_json for this purpose since the request and response transport will handle UTF-8 encoding.) |
JSON is just a string, so if you encode the hashref to JSON, you can pass it as a string value into a template or through a form. If you don't need the form to do anything with individual values this seems easiest. (Use from_json/to_json not encode_json/decode_json for this purpose since the request and response transport will handle UTF-8 encoding.)