我正在尝试在视图中使用simple_form
的Ruby 2.5 on Rails(v5.1)中的Bootstrap 3模式中使用haml
。
我希望能够将提交按钮放在模态页脚中,但这会破坏haml
约定。任何解决方法?
模态
#addDataModelModal.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "exampleModalLabel", role: "dialog", tabindex: "-1"}
.modal-dialog{role: "document"}
.modal-content
.modal-header
%h5#addDataModelModalLabel.modal-title Choose a Data Model
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", type: "button"}
%span{"aria-hidden" => "true"} ×
.modal-body
.text-center
= simple_form_for @project, :url => add_project_datastores_project_path, :method => 'post' do |f|
= f.input :project_datastores, collection: @datastores, label_method: :name, value_method: :datastore_sid, prompt: "Select a Data Model"
= f.submit 'Add Data Model', :class => 'pull-right btn btn-primary'
.modal-footer
%button.btn.btn-secondary{"data-dismiss" => "modal", type: "button"} Close
.text-center
答案 0 :(得分:2)
从= simple_form_for
div下面的.modal-content
开始,这样您就可以将f
变量插入其所有子级div中。
#addDataModelModal.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "exampleModalLabel", role: "dialog", tabindex: "-1"}
.modal-dialog{role: "document"}
.modal-content
= simple_form_for @project, :url => add_project_datastores_project_path, :method => 'post' do |f|
.modal-header
%h5#addDataModelModalLabel.modal-title Choose a Data Model
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", type: "button"}
%span{"aria-hidden" => "true"} ×
.modal-body
.text-center
= f.input :project_datastores, collection: @datastores, label_method: :name, value_method: :datastore_sid, prompt: "Select a Data Model"
.modal-footer
%button.btn.btn-secondary{"data-dismiss" => "modal", type: "button"} Close
.text-center
= f.submit 'Add Data Model', :class => 'pull-right btn btn-primary'