I am not able to get reagent-forms
to bind to an atom. I have data binding working in reagent elsewhere in the same file. And I can set and display the atom in question as expected.
I have
form-doc
that returns a[:div]
vector with inputs I'd like boundform-test
that creates an atom and callsbind-forms
secretary
route defined for/#/test
It seems like the :field
key within the form-doc
return value is ignored or not parsed by bind-fields.
In the test example below, the date picker is never displayed and the inputs look no different than [:input ]
would.
Am I using reagent-forms
incorrect? Missing a js dependency?
Browser rendered HTML of localhost.localdomain:3000/#/test
<div data-reactid=".5.0.0">
<input id="foobar" data-reactid=".5.0.0.0">
<input id="test" data-reactid=".5.0.0.1">
<input id="nofieldtest" data-reactid=".5.0.0.2">
<div id="picker" data-reactid=".5.0.0.3"></div>
</div>
in core.cljs
(ns ...
( :require
...
[reagent.core :as reagent :refer [atom]]
[reagent.session :as session]
[secretary.core :as secretary :include-macros true]
[reagent-forms.core :as rf ]
[json-html.core :refer [edn->hiccup]]
))
(defn form-doc []
[:div
[:input {:field :text :id :foobar}]
[:input {:field :text :id :test}]
[:div {:field :datepicker
:id :picker
:date-format "yyyy/mm/dd"
:inline true}]
]
)
(defn form-test []
(let [doc (atom {:test "test"} ) ]
(fn []
[:div.new-visit-form
[rf/bind-fields form-doc doc ]
[:div (edn->hiccup @doc) ]
]))
)
(secretary/defroute "/test" []
(session/put! :current-page #'form-test))
in ring/compojure handler I have
(include-js "//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js")
(include-js "//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js")
(include-css "//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css")
(include-css "//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css")
[:style (-> "reagent-forms.css" clojure.java.io/resource slurp) ]
as far as I can tell, all the necessary js and css is loaded by the browser
in project.clj
's :dependencies
[reagent "0.5.1"]
[reagent-utils "0.1.5"]
[reagent-forms "0.5.13"]