I understand nitro did undergo a huge refactoring process, and as one result the Control system was futher improved.
I have always dreamed of making my own, custom, flexile and easy to use control system. I spent 25%++ time making CRUD forms by hand.
Could some ruby guru please let us know how this works with nitro 0.40?
(1 attempts)
Fabian answered:
The new form helper can be used in a template as follows:
#{form(:object => OgModel, :action => :some_action_method) do |f|
f.attributes
f.submit 'Save'
end}
Where "OgModel" can be any Og managed class or you can also give it an instance (maybe created in your appropriate action).
With the above all attributes of your Model are used (except relation attributes). If you want a single attribute to not show up, you can either use the old way (":control => :none" in your model) or with the :exclude keyword:
#{form(:object => OgModel, :action => :some_action_method) do |f|
f.attributes(:exclude=>[:foo1, :foo_attr2])
f.submit 'Save'
end}
If you just want to cherry-pick some attributes for your form, you can do it as follows:
#{form(:object => OgModel, :action => :some_action_method) do |f|
f.attribute :foo
f.attribute :bar
f.submit 'Update'
end}
Relations can be handled via "f.relation :some_rel" for a single relation and "f.relations" for all relations of a model.
Additionally you can use other stuff of the xhtml builder:
#{form(:object => OgModel, :action => :some_action_method) do |f|
f.hidden :oid, @some_other.oid
f.attribute :foo, :editable => false
f.p do
f.attribute :bar
end
f.br
f.submit 'Update'
end}