To allow common form "snippets" to be reused consistently across a site, we should allow them to be composed onto other forms. Something like this:
class MyForm < Formalist::Form
# Normal form definition
field :title, type: :text
# Compose another form object and use it for all the data inside the `venue` key
attr :venue, form: :venue_details
end
my_form = MyForm.new(venue_details: another_form_object)
Using symbols as the external form references here allows us to pass them in as fully configured form instances when the form is created. It also means we can use them at any depth within the form definition.
Once we add support for validation, etc., we'll need to make sure all of that info merges into the main form nicely too.
From the example above, it's pretty clear how we could use external forms on attr and many definitions. What's not so clear is how you could just "inline" an external form at any arbitrary point. Maybe we need to add an import :some_other_form definition?
To allow common form "snippets" to be reused consistently across a site, we should allow them to be composed onto other forms. Something like this:
Using symbols as the external form references here allows us to pass them in as fully configured form instances when the form is created. It also means we can use them at any depth within the form definition.
Once we add support for validation, etc., we'll need to make sure all of that info merges into the main form nicely too.
From the example above, it's pretty clear how we could use external forms on
attr
andmany
definitions. What's not so clear is how you could just "inline" an external form at any arbitrary point. Maybe we need to add animport :some_other_form
definition?