Rails提交按钮不能使用类

时间:2021-01-06 19:43:33

Simple Rails form inside of a Modal.

简单的Rails形成一个模态。

Will Work: <%= submit_tag "New Form", :class => "waves-button-input" %>

将工作:<%= submit_tag“新表格”,:class =>“waves-button-input”%>

Will Not Work:

不管用:

<%= submit_tag "New Form", :class => "waves-effect waves-green btn-flat waves-button-input" %>

I've tried doing this via <input> tags, submit tags, form submission POSTs etc. For some reason adding those classes break it.

我已经尝试通过标签,提交标签,表单提交POST等进行此操作。由于某些原因,添加这些类会破坏它。

For full context my form:

完整的上下文我的表格:

<div id="projectModal" class="modal">
  <div class="modal-content">
    <div class="form-group">
    <%= form_tag(new_project_path, method: :get) %>
        <%= select_tag :project_type, options_for_select(Project.project_types.keys.to_a), :class => 'id_select', :id => 'secret_id'  %><br><br><br>
        <%#= text_field :client_id, %>
        <%= collection_select :project, :client_id, current_user.clients, :id, :name, :prompt => true %>

    </div>
  </div>
  <div class="modal-footer">
    <a class="modal-action modal-close waves-effect waves-green btn-flat modal-close">Cancel</a>
    <%= submit_tag "New Form", :class => "waves-button-input" %>

    <!--<input type="submit" name="commit" value="New Form" class="waves-effect waves-green btn-flat waves-button-input" data-disable-with="New Form">-->
    <!--<input type="submit" name="commit" value="New Form" class="waves-button-input" data-disable-with="New Form">-->
  </div>
</div>

On click all it does is change the <i> to color and full effect but makes 0 effort to send the data. Normally I would think turbolinks or something but since it works without the stylization I'm confused.

单击它所做的全部是将更改为颜色和完整效果,但是努力发送数据。通常我会认为turbolinks或者其他东西但是因为它没有程式化而工作我很困惑。

1 个解决方案

#1


1  

Try to add id to form and to submit tag

尝试将id添加到表单并提交标记

= form_tag(new_project_path, method: :get, id: 'formId')

= submit_tag "New Form", :class => "waves-effect waves-green btn-flat waves-button-input", form: 'formId'

#1


1  

Try to add id to form and to submit tag

尝试将id添加到表单并提交标记

= form_tag(new_project_path, method: :get, id: 'formId')

= submit_tag "New Form", :class => "waves-effect waves-green btn-flat waves-button-input", form: 'formId'