Module: Reform::Form::Sync::SkipUnchanged
- Defined in:
- lib/reform/form/sync.rb
Overview
This will skip unchanged properties in #sync. To use this for all nested form do as follows.
class SongForm < Reform::Form
feature Synd::SkipUnchanged
Instance Method Summary collapse
Instance Method Details
#sync_hash(options) ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/reform/form/sync.rb', line 105 def sync_hash() # DISCUSS: we currently don't track if nested forms have changed (only their attributes). that's why i include them all here, which # is additional sync work/slightly wrong. solution: allow forms to form.changed? not sure how to do that with collections. scalars = mapper.fields { |dfn| !dfn[:form] } unchanged = scalars - changed.keys # exclude unchanged scalars, nested forms and changed scalars still go in here! .exclude!(unchanged.map(&:to_sym)) super end |