reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Collection editor #44

Closed yayitswei closed 9 years ago

yayitswei commented 9 years ago

How would I create a set of text boxes, with each textbox editing a value in a vector, and the ability to add/subtract elements?

Since the template is evaluated eagerly, I can't generate the text boxes directly from the vector.

yogthos commented 9 years ago

The best way at the moment would be to create a new defmethod for init-field as described in the custom fields section in the readme.

The element could then keep an atom for the local state, i.e. current element. Then on change it would populate the doc with the result. The typeahead element is an example of a similar behavior.

yayitswei commented 9 years ago

Thanks for the suggestion, that approach is working for me so far.

Why do get and save work inside of the render-element form, but dereferencing the source atom doesn't, for updating the view based on the source data?

yogthos commented 9 years ago

If you're referencing the atom inside on the :field elements that will likely get lost since bind-field will create a new component. However, it's generally better to use get and save! functions as they will trigger events.