How can I set the class and id attribute for the form element through semantic_form_for?
如何通过semantic_form_for为表单元素设置class和id属性?
The following code:
以下代码:
<% semantic_form_for (@meetingsearch), :class => "new_meeting_search", :id => "meeting_search" do |f| %>
gives me:
给我:
<form action="/meetingsearches" class="formtastic meetingsearch" id="new_meetingsearch" method="post">
1 个解决方案
#1
59
This should do what you need (untested):
这应该做你需要的(未经测试):
<% semantic_form_for @meetingsearch, :html => { :class => "new_meeting_search", :id => "meeting_search" } do |f| %>
For clarification, semantic_form_for
wraps around Rails' built in form_for
, so this is exactly how you do it in regular Rails forms also:
为了澄清,semantic_form_for包含了在form_for中构建的Rails,所以这正是你在常规Rails表单中的表现:
<% form_for @meetingsearch, :html => { class => "new_meeting_search", :id => "meeting_search" } do |f| %>
#1
59
This should do what you need (untested):
这应该做你需要的(未经测试):
<% semantic_form_for @meetingsearch, :html => { :class => "new_meeting_search", :id => "meeting_search" } do |f| %>
For clarification, semantic_form_for
wraps around Rails' built in form_for
, so this is exactly how you do it in regular Rails forms also:
为了澄清,semantic_form_for包含了在form_for中构建的Rails,所以这正是你在常规Rails表单中的表现:
<% form_for @meetingsearch, :html => { class => "new_meeting_search", :id => "meeting_search" } do |f| %>