yada

agigao 2018-08-20T09:28:55.000100Z

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.

maleghast 2018-08-20T17:21:45.000100Z

Anyone about in here, today?

maleghast 2018-08-20T17:24:44.000100Z

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

tanzoniteblack 2018-08-20T17:25:24.000100Z

@maleghast can you post both how you're calling it?

tanzoniteblack 2018-08-20T17:25:50.000100Z

and also you're :parameters map

maleghast 2018-08-20T17:27:22.000100Z

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}))))}

maleghast 2018-08-20T17:28:09.000200Z

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.

tanzoniteblack 2018-08-20T17:29:02.000100Z

I think you might need to specify :parameters to get it to work, give me a sec to double check that

maleghast 2018-08-20T17:29:55.000100Z

Ah, ok, thanks

tanzoniteblack 2018-08-20T17:43:23.000100Z

@maleghast you should be able to do what you want by adding :parameters {:form {schema/Keyword schema/Any}} to your map

tanzoniteblack 2018-08-20T17:43:36.000100Z

without that, it'll just ignore the form parameters

tanzoniteblack 2018-08-20T17:44:16.000100Z

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}})

tanzoniteblack 2018-08-20T17:44:21.000100Z

but, you do you 🙂

maleghast 2018-08-20T18:38:54.000100Z

Thx very much! Sorry I didn’t respond sooner - was on the Tube

maleghast 2018-08-20T18:44:29.000100Z

I want to “get it working” quickly, but once it is I will define the schema properly ;-)