reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Documentation or example for dealing with maps with nested collections #57

Closed allumbra closed 8 years ago

allumbra commented 9 years ago

I want a form to edit a document (map) that has a contacts vector. It is unclear to me how to go about this using the library. Thanks!

yogthos commented 9 years ago

I'm not quite clear on the use case, could you provide a bit more specifics. Normally, if you have a collection of items you'd represent it with a list or a multiselect field.

KeeganMyers commented 8 years ago

Sorry if this is out of place my but my issue is very similar. Could you please document event handlers for nested collections? In the context of your live example this would be something like the BMI calculation but applied to the person's age. I've been attempting to create something along those lines for a project I'm working on. But the id parameter you are using to determine which field the change occurred on only returns the name of the top level data structure. In your example that would be person. So far I have:

(defn inc-age [[id] value { {:keys [age]} :person :as document}](when %28and %28some #{id} [:age]%29 age%29 %28assoc document :person %28 inc age%29%29))

But (inc age) is never hit because id will always say person, not person.age

yogthos commented 8 years ago

each event should accept 3 parameters, so the inc-age function should looks as follows:

(defn inc-age [id value {{:keys [age]} :person :as document}]
  ;;do stuff with age
  )