bilus / reforms

Beautiful Bootstrap 3 forms for Om, Reagent and Rum.
Eclipse Public License 1.0
168 stars 7 forks source link

Weird behavior #12

Closed piranha closed 3 years ago

piranha commented 8 years ago

Hi! I'll try to make this issue a bit better later, but I just discovered strange bug. When I write a form like this:

(rum/defc ChartForm < rum/cursored rum/cursored-watch
  [data ui-state]
  (v/form ui-state
    {:on-submit #(save-chart! data ui-state)}

    [:div
     (v/textarea {:style {:height 300}} data [:chart/query])

     (v/text "Name" data [:chart/name])
     (f/form-buttons
       (f/button-primary "Save" #(save-chart! data ui-state))
       (f/button "Cancel" #(handlers/toggle-editing (:db/id @data))))]))

my inputs are not shown and I see an error message saying Wrong number of args (3) passed to :div.row. What fixes it is wrapping :div in vec:

(rum/defc ChartForm < rum/cursored rum/cursored-watch
  [data ui-state]
  (v/form ui-state
    {:on-submit #(save-chart! data ui-state)}

    (vec
      [:div
       (v/textarea {:style {:height 300}} data [:chart/query])

       (v/text "Name" data [:chart/name])
       (f/form-buttons
         (f/button-primary "Save" #(save-chart! data ui-state))
         (f/button "Cancel" #(handlers/toggle-editing (:db/id @data))))])))

Not sure what's going on here, but it took me some time to figure out what to do. :)

bilus commented 8 years ago

Is the problem gone if you switch to the normal form (without validation)?

bilus commented 8 years ago

I think I may have a fix for it. I just pushed a reagent version of the library that fixes what I think is a related problem (issue #11). Once I'm certain everything's all right, I'll notify the author of rum bindings and we'll push out an update.

If you also use reagent it would be tremendous if you could help by testing reagent-reforms 0.4.4-SNAPSHOT (validation and markup similar to what you shown above)!