简体   繁体   English

使用haml在bootstrap模式中创建simple_form

[英]Create simple_form in bootstrap modal with haml

I'm trying to use simple_form in a Bootstrap 3 modal in Ruby 2.5 on Rails (v5.1) with haml in the view. 我试图用simple_form与on Rails的(V5.1)中的Ruby 2.5的引导模式3 haml在视图中。

I want to be able to put the submit button in the modal footer, but this breaks the haml conventions. 我希望能够将提交按钮放在模态页脚中,但这会打破haml约定。 Any workarounds? 任何解决方法?

Modal 语气

#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

start the = simple_form_for right below the .modal-content div so you can insert your f variable into all its children divs. .modal-content div下面启动= simple_form_for这样你就可以将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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM