Thanks Malcolm! yeah I’m quite excited about the project, but somehow Yada docs seem to let me down quite often. I’ve opened an issue at github edge repo.
Anyone about in here, today?
I am trying to work with a form, but the resource is not parsing the form body automatically, so the only thing I have is the :body key in the context, no [:parameters :form], in fact :parameters is an empty map {} I am wondering if there is a different thing I need to do to define the resource..? At the moment I am saying that it consumes: application/x-www-form-urlencoded
@maleghast can you post both how you're calling it?
and also you're :parameters
map
The form in the HTML page uses: method="post" action="[URL HERE]" The :post section of the resource looks like this:
:post
{:consumes [{:media-type #{"application/x-www-form-urlencoded"}
:charset "UTF-8"}]
:response
(fn [ctx]
(println ctx)
(let [formdata (:body ctx)
db-insert-result (add-organisation-to-db formdata)]
(case (yada/content-type ctx)
"text/html" (selmer/render-file
"admin/organisation-new-add.html"
{:title ""
:data db-insert-result
:ctx ctx}))))}
I don't have a :parameters map in the Resource definition - I just want the whole form to be tokenised and turned into a keyword-based map.
I think you might need to specify :parameters
to get it to work, give me a sec to double check that
Ah, ok, thanks
@maleghast you should be able to do what you want by adding :parameters {:form {schema/Keyword schema/Any}}
to your map
without that, it'll just ignore the form parameters
side note: It's better to explicitly list the parameters you want sent to this endpoint in the :parameters
schema (i.e. {:form {:param1 schema/String :param2 schema/Num}}
)
but, you do you 🙂
Thx very much! Sorry I didn’t respond sooner - was on the Tube
I want to “get it working” quickly, but once it is I will define the schema properly ;-)