"meeting_search" do |f| -6ren">
gpt4 book ai didi

ruby-on-rails - Formtastic 设置类和表单 id

转载 作者:行者123 更新时间:2023-12-03 09:44:27 25 4
gpt4 key购买 nike

如何通过semantic_form_for为表单元素设置class和id属性?

以下代码:

<% semantic_form_for (@meetingsearch), :class => "new_meeting_search", :id => "meeting_search" do |f| %>

给我:
<form action="/meetingsearches" class="formtastic meetingsearch" id="new_meetingsearch" method="post"> 

最佳答案

这应该做你需要的(未经测试):

<% semantic_form_for @meetingsearch, :html => { :class => "new_meeting_search", :id => "meeting_search" } do |f| %>

为澄清起见, semantic_form_for环绕 Rails 的内置 form_for ,所以这正是您在 regular Rails forms also 中的做法:
<% form_for @meetingsearch, :html => { class => "new_meeting_search", :id => "meeting_search" } do |f| %>

关于ruby-on-rails - Formtastic 设置类和表单 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2047497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com