ruby-on-rails – Rails simple_form,在输入之前移动提示
发布时间:2020-12-16 21:21:17 所属栏目:百科 来源:网络整理
导读:无论如何移动提示组件使其出现在输入之前? 当前显示的组件按以下顺序显示:标签,输入,提示,错误.我尝试添加:components选项,但这不起作用. 这是我的代码: %= f.input :content,:components = [:label,:hint,:input],:as = :text,hint: 'Please 1) include
无论如何移动提示组件使其出现在输入之前?
当前显示的组件按以下顺序显示:标签,输入,提示,错误.我尝试添加:components选项,但这不起作用. 这是我的代码: <%= f.input :content,:components => [:label,:hint,:input],:as => :text,hint: 'Please 1) include your exact copy here,2) upload your copy document in the next step,or 3) describe any content services to include in our estimate.',required: true,:label => "Copy" %> 解决方法
您可以在以下位置修改config / initializers / simple_form.rb中的Inputs部分默认包装器:
b.use :label_input b.use :hint,wrap_with: { tag: :span,class: :hint } b.use :error,class: :error } 至: b.use :label b.use :hint,class: :error } b.use :input 本节从默认生成的simple_form.rb的第42行开始 这将使单个复选框在出现错误时看起来有点奇怪,因此您还需要创建一个与原始配置重复的包装器版本,并将其设置为仅用于布尔输入类型.例如: config.wrappers :checks,class: :input,hint_class: :field_with_hint,error_class: :field_with_errors do |b| b.use :html5 b.use :placeholder b.optional :maxlength b.optional :pattern b.optional :min_max b.optional :readonly ## Inputs b.use :label_input b.use :hint,class: :hint } b.use :error,class: :error } end config.wrapper_mappings = { boolean: :checks } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |