我的视图中有一个嵌套的表单;
<%= simple_form_for @form, url: url do |f| %>
<%= f.input :name %>
<%= f.input :description, as: :text %>
<%= f.fields_for :account, { :class => 'field' } do |ff| %>
<%= ff.collection_radio_buttons(:account_type_id, AccountType.all, :id, :name, selected: ff.object.account_type_id) { |b| radio_button_builder(b) } %>
<% end %>
这是我的Form对象(扩展了改革);
class ProgrammeForm < ApplicationForm
properties :name, :description, validates: {presence: true}
property :account do
property :account_type_id
validates :account_type_id, presence: true
end
end
如果我在不填写任何字段的情况下提交表单,那么我的<% if @form.errors.any? %>
部分会打印出三个错误;
3 Errors prohibited this from being saved:
Name can't be blank
Description can't be blank
Account account type can't be blank
但我的嵌套表单上没有“看错”的HTML(account_type的东西)。名称和描述都很好(因为这些都很简单)。但;
fields_for
不会在单选按钮集合周围放置div包装器。我如何解决这两点?