reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

:datepicker #20

Closed radirk closed 9 years ago

radirk commented 9 years ago

Is the :datepicker field option working yet? Have tried different things and didn't get errors, but nothing displays on the page. An example would be very helpful. Thanks.

yogthos commented 9 years ago

The datepicker should be working, you can create one as follows:

[:div {:field :datepicker :id :date :date-format "yyyy/mm/dd" :inline true}]

You also need to include the provided css for it to render correctly. It can be read as follows:

(defn resource [r]
 (-> (Thread/currentThread)
     (.getContextClassLoader)
     (.getResource r)
     slurp))

(resource "reagent-forms.css")

Then simply make sure it's included on the page, if you're using Selmer then it's something like

(render "page.html" {:datepicker-css (resource "reagent-forms.css")})

Then on the page:

<style>{{datepicker-css}}</style>
radirk commented 9 years ago

Ok, working now. My template definition was wrong. Thanks!

radirk commented 9 years ago

Also took me a while to learn that the date has to be passed as a hash: {:year 2014 :month 11 :day 24}. May help some people.

yogthos commented 9 years ago

ah good point, I'll update the docs