Ruby on rails 如何在Rails 4应用程序中将类添加到表单_for helper?
我正在使用bootstrap CCS来设计Rails 4应用程序的样式,但在使用表单_for helper时,我不知道如何将类添加到表单中。我在其他几个线程上遵循了这些建议,但没有成功。两条这样的线Ruby on rails 如何在Rails 4应用程序中将类添加到表单_for helper?,ruby-on-rails,haml,form-for,Ruby On Rails,Haml,Form For,我正在使用bootstrap CCS来设计Rails 4应用程序的样式,但在使用表单_for helper时,我不知道如何将类添加到表单中。我在其他几个线程上遵循了这些建议,但没有成功。两条这样的线 该应用程序的工作,因为它应该按照指示,但我希望它看起来也不错。这是工作代码,注释掉了第一行,因为它没有像我需要的那样向表单添加额外的类 有人能帮我应对这个挑战吗?希望今天有一些smart Rails开发人员可以提供帮助。您可能已经得到了答案,不过以下几点可能会对您有所帮助 类名称为ha
有人能帮我应对这个挑战吗?希望今天有一些smart Rails开发人员可以提供帮助。您可能已经得到了答案,不过以下几点可能会对您有所帮助 类名称为haml的表格:
= form_for @patient, :html => {:class => "form-horizontal"} do |f|
它也可以写成
= form_for @patient, {:html => {:class => "form-horizontal"}} do |f|
- form_for @patient, :html => {:class => "form-horizontal"} do |f| #it gives error.
但它不能被写成
= form_for @patient, {:html => {:class => "form-horizontal"}} do |f|
- form_for @patient, :html => {:class => "form-horizontal"} do |f| #it gives error.
希望有帮助 你可能已经得到了答案,尽管以下几点可能会对你有所帮助 类名称为haml的表格:
= form_for @patient, :html => {:class => "form-horizontal"} do |f|
它也可以写成
= form_for @patient, {:html => {:class => "form-horizontal"}} do |f|
- form_for @patient, :html => {:class => "form-horizontal"} do |f| #it gives error.
但它不能被写成
= form_for @patient, {:html => {:class => "form-horizontal"}} do |f|
- form_for @patient, :html => {:class => "form-horizontal"} do |f| #it gives error.
希望有帮助 除了Pavan在Rails 4中的答案之外,如果您使用的是表单标签,您可以这样写:
= form_tag some_path, method: 'get', class: 'some-class' do
这对我很有用。除了Pavan在Rails 4中的答案,如果您使用的是表单标签,您可以这样写:
= form_tag some_path, method: 'get', class: 'some-class' do
这对我很有效。您在为@patient,:html=>{:class=>“form horizontal”}do | f |使用这行时是否有任何错误?没有错误。页面仍在加载,但当我查看源代码时,没有添加该类。这非常奇怪,因为我刚刚再次尝试,它仍然有效。这个班已经换了。我没有做任何与我写问题之前不同的事情。嗯,你可以重新启动服务器吗?这也可以工作,我想是这样的
form_for@patient,{:html=>{:class=>“form horizontal”}do | f |
你在使用这行form_for@patient,:html=>{:class=>“form horizontal”}时有没有错误您是否已注释了| f |
?无错误。页面仍在加载,但当我查看源代码时,没有添加该类。这非常奇怪,因为我刚刚再次尝试,它仍然有效。这个班已经换了。我没有做任何与我写问题之前不同的事情。嗯,你可以重新启动服务器吗?我想这也可以。form_for@patient,{:html=>{:class=>“form horizontal”}do | f |
谢谢Pavan!这真的帮了我很大的忙,因为我能够很好地填写表格。谢谢Pavan!这真的很有帮助,因为我能够进去,并起草了一份很好的表格。