-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to parse to joda dates #23
Comments
Perhaps related to this, I can not get a datetime to render correctly. I posted some screenshots of the problem on my blog: http://www.smashcompany.com/technology/trying-to-use-the-formative-library Is that a bug, or do I need to reformat the datetime to get it to work? |
Might be a bug. Could you verify the class of the date before passing it to Formative? E.g. with |
Okay, this: (println (str (class (:created-at item)))) gives me: class org.joda.time.DateTime Do I need to coerce this to a different type? This value is probably coming back to me straight from the driver that connects to MongoDb, though elsewhere in my code I rely on https://github.com/clj-time/clj-time for handling of dates. |
Apparently, I was able to fix this problem by adding the special keys "year-start" and "year-end". Perhaps the documentation could make clear that these keys are mandatory? I ended up with this field definition: { My thanks to you for the work you've done on Formative. It is a good library. |
Actually I can not get this to work. I am using (wrap-keyword-params) so most of the form inputs are keywords, but not the datetime-select inputs, which for some reason remain strings. If I use pprint on the form input I see data like: "created-at[month]" "11", All of the field names are correctly transformed to keywords, except for the datetime-select forms. More so, when I validate the form: (fp/parse-params the-form (:params request)) The datetime-select fields simply vanish from the item. I looked here: https://github.com/jkk/formative/blob/master/src/formative/parse.cljx and it seems like the code can parse datetime-select. What do I need to do to enable this? Is there a :datatype that I need to set? Or is there specific Ring middleware I should use? Or does (wrap-keyword-params) actually block the workings of Formative? |
Huh. This is strange. Even if I manually create a datetime and put it into the (:params request) Formative still removes it when it validates the data. Right now I have this clunky bit of code, with a pprint at top and pprint at bottom: (println " these values will be validated by formative: ") And this: (tyme/make-created-at item) is a clunky way to force a datetime: (defn make-created-at [item](if %28get-in item) "tyme" is just a refer to clj-time. The pprint shows the datetime-select input with string keys like this: "updated-at[year]" "", The bottom pprint surprises me: the datetimes have been removed. Formative gives no error, no exception, Formative simply removes the datetime. I am trying to figure out why this is. |
Looking here: https://github.com/jkk/formative/blob/master/src/formative/parse.cljx I see:
So I added a "timezone" as string:
This did not help. |
Could you try |
This: (pprint request) shows me (among other things): :form-params {}, all data is in: :multipart-params and: :params These last 2, :multipart-params and :params, have similar content, but :multipart-params have keys that are strings. (wrap-keyword-params) gives me keyword keys in :params, but not in :multipart-params. I do not know why :form-params is empty. Maybe I have wrap-params in the wrong place? I have my Ring middleware set up as: (def app I just tried: (def app but then I am unable to log in, so I moved wrap-params back to the end. Am I missing any middleware that is necessary to work with Formative? I didn't see anything special in the demo app you've set up. If I access :multipart-params and send that to parse-params, like this:
I get: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.CharSequence I am guessing that the clojure.lang.PersistentArrayMap causing the problems is the file maps being uploaded, such as: "file-1" In this case I did not upload a file, but the map is still there in :multipart-params. |
Must account for this in validations, too - does Verily need to be updated?
The text was updated successfully, but these errors were encountered: