HAML and Forme #81
jeremyevans
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Google Group Post: https://groups.google.com/g/ruby-forme/c/rpioO09taw0
Google Group Date: Wed, 26 Jul 2017 11:19:47 -0700
Google Group Sender: [email protected]
Hi,
Should the Forme object be declared in the controller, or should it be
declared in the view?
Sinatra's controller:
get ('/') do
@Form = Forme.form(:action => url('/address')) do |f|
f.input(:text, :name => 'address', :label => 'Address', :required => true)
f.input(:select, :name => 'radius', :options => [5, 10, 15, 20], :label => 'Miles')
f.input(:select, :name => 'business', :options => ['All', 'Commercial', 'Exchange', 'Medicare'], :label => 'LOB')
f.input(:checkbox, :name => 'pediatrics', :as => :checkbox, :label => 'Pediatrics Only')
f.button('Search')
end
haml :main
end
Haml View:
= @Form
I cannot do styling with this approach. So I try to use Forme in the view
Haml View:
= Forme.form(:action => url('/address')) do |f|
= f.input(:text, :name => 'address', :label => 'Address', :required => true)
= f.input(:select, :name => 'radius', :options => [5, 10, 15, 20], :label => 'Miles')
= f.input(:select, :name => 'business', :options => ['All', 'Commercial', 'Exchange', 'Medicare'], :label => 'LOB')
.checkbox
= f.input(:checkbox, :name => 'pediatrics', :as => :checkbox, :label => 'Pediatrics Only')
= f.button('Search')
Sinatra's route:
get ('/') do
haml :main
end
But this is not correct either because the form appears twice on the page.
So what is the correct way to use Forme?
Beta Was this translation helpful? Give feedback.
All reactions