Tag: 简单forms

Rails 4 – 具有简单forms的依赖字段的JS

我想在Rails 4中创建一个应用程序。 我正在使用简单的表单forms,并且刚刚尝试使用gem’inpendent-fields-rails’来隐藏或显示基于主要问题的表单字段的子集问题。 我卡住了。 我已将gems添加到我的gem文件中: gem ‘dependent-fields-rails’ gem ‘underscore-rails’ 我已将我的application.js更新为: //= require dependent-fields //= require underscore 我的表格有: “Is this a project in which students may participate?”, autofocus: true %> “Is this a project students complete for credit towards course assessment?” %> “Is this project offered on a recurring basis?” %> “How often is this project […]

在Bootstrap Ajax模式中使用simple_form显示内联错误

我在这里和这里找到了类似的StackOverflow问题,但仍然无法使其工作。 我正在使用Rails 3.2.8,SimpleForm 2.0.4和Twitter Bootstrap 2.1.1(通过bootstrap-sass gem 2.1.1.0)。 用户应该能够从模态弹出窗口添加联系人。 如果存在validation错误,它们应该显示为内联,就像用户使用表单的非模态版本(字段周围的红色边框,字段旁边的错误消息)一样。 我像这样加载模态: Go modal! 这是Bootstrap模式,它调用非模态版本中部分使用的相同contacts/contact_fields 。 app / views / contacts / _new_modal.html.erb : × true, :html => {:class => “form-horizontal”, “data-type” => :json }) do |contact_form| %> contact_form %> “btn btn-primary”, :”data-loading-text”=> (‘simple_form.creating’) %> app / controllers / contacts_controller.rb (故意注释掉format.json行,因为我试图用JavaScript发回整个模态): def create @contact = Contact.new(params[:contact]) […]