Giter VIP home page Giter VIP logo

formative's People

Contributors

abp avatar ayato-p avatar davewm avatar iku000888 avatar jkk avatar mynomoto avatar rippedathlete avatar swalkinshaw avatar thornjad avatar yayitswei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

formative's Issues

:datetime datatype

what string format to use? anything compatible with clojure.instant/read-instant-date?

No credit card field?

Formative should have a built in credit card field, that spaces numbers by four and checks if the correct number of digits is entered.

`required` DOM attribute

The required DOM attribute is filtered out when rendering a select box field, for instance:

(let [attrs (get-input-attrs field [:name :id :class :autofocus
:disabled :multiple :size :readonly
:tabindex :onchange :onclick :onfocus
:onblur])

It's quite a useful attribute, should probably add it to the field whitelist above.

add getf, getf1 to help with nested values?

(getf :foo.bar {:foo {:bar 1}}) => 1
(getf "foo[bar]" {:foo {:bar 1}}) => 1
(getf "foo[bar]" {"foo" {"bar" 1}}) => 1
(getf "foo[bar]" {"foo[bar]" 1}) => 1

For :flatten fields?
(getf "foo[bar]" {"foo-bar" 1})
(getf "foo" {"foo-bar" 1 "foo-qux" 2}) => {"bar" 1 "qux" 2"}) ???

Drop cljx

Reader conditionals are in town + cljx is deprecated so we are better of migrating to cljc

Add doc reg. attributes with data prefix will be rendered.

There is the following undocumented behaviour that is works well with bootstrap, which would be nice to have it right in the readme.

(f/render-field {:name :my-text :data-x 10 :data-y 20})
;; (nil [:input {:type "text", :name "my-text", :value "", :data-x 10, :data-y 20}])

Custom inline anonymous functions for field type?

Thank you for all the great work on formative.

I have a request: could you add a field "type" that allows us to add in an inline anonymous function for handling that field? For simple HTML formatting I'd rather define the function inline that invent a custom method with:

(defmethod render-field :hyperlink-value ;;;; code here)

My scenario:

Assume I have something like weblog software, so I have "posts" and "users". Each post is owned by 1 user. On the admin form that allows an admin to edit the "posts", I want the "user-id" field to be a hyperlink that could take an admin from the "post" record to the owning "user" record.

I could:

(defmethod render-field :hyperlink-value ;;;; code here)

Or I could make the presentational HTML fields work to this purpose (I assume).

But I'd rather just define an anonymous function inline, for relatively rare stuff like this.

fixing bootstrap3-horizontal

Thanks for making formative! I've found it very useful so far.

I noticed the bootstrap3-horizontal form is broken. What would it take to fix it?

;; Broken
#_(defmethod render-form :bootstrap3-horizontal [form-attrs fields opts]
   (render-bootstrap-form form-attrs fields "form-shell form-horizontal" opts))

I'm using the latest version of Bootstrap, and the stacked layout doesn't look appropriate for desktop window sizes.

Controlled Field Wrappers

It looks as though you are assuming a labeled input field when a new field type is defined and implemented by adding a new render-field method. This means you can't introduce a new field type similar to a heading, or some regular HTML.

It looks as though you're using sets containing field types to make decisions about lots of things, not just wrapping format, e.g. you're using a set to define what field types separate field-sets.

It might be nice to name (and document) these sets, and even nicer if you could make them dynamic so we could change their contents with a binding. (I'd be able to control what kind of wrapper the new field type has, and if it separates field-sets, and more).

It might be necessary to add additional multimethods to completely control this stuff.

And it's getting complicated, but at least there's reasonable defaults.

Does that make any sense?

Enable use of sets for options

When specifying elements like checkboxes and selects where options are passed for the values to be displayed, there should be the possibility to use sets just as one can use vectors.

Example:

{ :fields [ {:name :grouped-by 
              :type :radios 
              :options #{"year" "month" "day"}}]
}

`fp/normalize-params` gives different results with keyword params

Thanks for the handy library!

I'm running into a problem trying to use checkbox fields with wrap-keyword-params.

See two params maps, extracted from a test application, one with wrap-keyword-params and one without. "disclaimer" is the name of a field that looks like {:name :disclaimer :type :checkbox}

(def pms {"submit" "Submit", "disclaimer" ["false" "true"]})

(def kpms {:submit "Submit", :disclaimer ["false" "true"]})

(#'fp/normalize-params pms)
;;=> {"disclaimer" "true", "submit" "Submit"}

(#'fp/normalize-params kpms)
;;=> {"submit" "Submit", "disclaimer" ["false" "true"]}

The keyword version causes a problem later when we call something like

(parse-input {:datatype :boolean} ["false" "true"])
;;=> java.lang.IllegalArgumentException
;;=> No matching method found: valueOf
;;=> parse.clj:43
;;=> ...

fieldsets

Two approaches come to mind:

  • Handle it in the renderer by splitting on :heading
  • Create a :fieldset field type that contains other fields

Validator for :options

Decide whether this should be the default. Have a way to opt out if so. Maybe a field key?

java.lang.IllegalArgumentException: No matching method found: valueOf

Any thoughts about what could trigger this error? I get it when I try to parse the form input:

item-type-as-keyword (keyword (get-in request [:params :item-type]))

the-form (secretary/get-from-interactions [:schema item-type-as-keyword])

item (:params request)

item (if (:item-name item)
item
(assoc item :item-name (make-item-name item)))

item (fp/parse-params the-form item)

That last line triggers the error.

"the-form" is the Formative form definition. "item" is the :params from request when the form is submitted.

It would be nice to have a form builder like ngFormBuilder from Form.io

Hi,

I saw ngFormBuilder from form.io and I think it is great for prototyping and fast form development.
It would be great if Formative could have something like this.
I saw there is a form renderer in the examples but no form builder.

I've posted the question here as well https://clojureverse.org/t/are-there-any-gui-form-builders-in-clojure-script-world-like-from-ios-ngformbuilder/6212 .

The whole form.io ecosystem comes a lot of features that you can use to deliver a working app/ prototype very fast.

Why do you create a hidden input field for a checkbox?

When I try to render a checkbox I get an extra hidden input field.
Is this necessary?

(form-core/render-form {:fields [{:name :some-nome :label "Some Label"  :type :checkbox}]
                        :values {}
                        :submit-label "Submit"})

[:div
 {:class "form-shell form-horizontal bootstrap-form"}
 nil
 [:form
  {:method "POST"}
  (()
   ([:fieldset
     {:class "fieldset-some-nome"}
     ([:div
       {:id "row-field-some-nome", :class "field-group  control-group checkbox-row"}
       ([:div {:class "empty-shell"} nil]
        [:div
         {:class "input-shell controls"}
         nil
         [:label.checkbox
          {:for "field-some-nome"}
          " "
          ((nil [:input {:value "false", :name "some-nome", :type "hidden"}])
           (nil [:input {:checked false, :value "true", :id "field-some-nome", :name "some-nome", :type "checkbox"}]))
          " "
          [:span.cb-label "Some Label"]]
         nil
         nil
         nil])])]
    [:fieldset
     {:class "fieldset-submit"}
     ([:div
       {:id "row-field-submit", :class "form-actions submit-group  control-group submit-row"}
       ([:div {:class "empty-shell"} nil]
        [:div
         {:class "input-shell"}
         nil
         (nil [:input {:value "Submit", :class " btn btn-primary", :id "field-submit", :name "submit", :type "submit"}])
         nil
         nil
         nil])])]))]]

fancier file upload type

  • show current value, checkbox to delete, file input for new upload
  • parses to map with current value, checkbox value, new upload
  • multiple uploads?

Automatic :datatype validation

When specifying a :datatype on fields, validation raises error-messages, but those aren't customizable.

Could you make the messages customizable, please?

Preventing XSS with Formative

I noticed the formative.util/escape-html function implemented to sanitise incoming HTML. Is there a way to tell Formative to escape incoming strings for certain form definitions?

Compound field type

Should labels/layout be handled specially?

:separator - what to put in between rendered fields

:combiner - how to combine rendered fields - (fn [fields-by-name] ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.