Models:
class Person
include ActiveModel::Model
attr_accessor :name, :pet
end
class Pet
include ActiveModel::Model
attr_accessor :name, :kind
end
Forms:
class PetForm < Reform::Form
property :name
property :kind
end
class PersonsForm < Reform::Form
property :name
#nested form with do..end block
=begin
property :pet do
property :name
property :kind
end
=end
# nested form with form option
property :pet, form:PetForm
end
ERB tpl:
<!-- main form -->
<%= form_for(@persons_from, as: :person, url: '/dashboard/person', method: "put") do |form| %>
<%= form.text_field :name, autofocus: true, placeholder:"Person Name", class:"rui-input" %>
<!-- nested form -->
<%= form.fields_for :pet, @persons_from.pet do |sub_form| %>
<%= sub_form.text_field :name, autofocus: false, placeholder:"Pet Name", class:"rui-input" %>
<%= sub_form.text_field :kind, autofocus: false, placeholder:"Pet Kind", class:"rui-input" %>
<% end %>
<%= submit_tag("Submit", :class => "rui-button-brand rui-mobile-block", :id => "submit") %>
<% end %>