1

我需要将自定义 html 添加到由 simple_form 生成的提示和错误元素中。最好我想通过配置文件自定义它。生成的 html 看起来像这样

span.error
  Some error message

理想的输出:

span.error
 span.icon.alert
 Some error message
4

1 回答 1

0

也许简单地为 .error 类添加背景图像(警报图标)?

或尝试在配置中附加包装器:

config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper :tag => 'div', :class => 'controls' do |ba|
  ba.use :input
  ba.wrapper :tag => 'div', :class => 'controls' do |input|
    input.wrapper :tag => 'span', :class => 'error-append' do |append|
      append.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
    end
  end
  ba.use :hint,  :wrap_with => { :tag => 'p', :class => 'help-block' }
end

结尾

于 2013-04-04T09:16:23.807 回答