【问题标题】:Rails ActiveAdmin active_admin_form_for submit button disabledRails ActiveAdmin active_admin_form_for 提交按钮已禁用
【发布时间】:2021-07-20 21:06:30
【问题描述】:

我有一个表单,其中有许多嵌套表单,每个表单都有提交按钮。我想根据特定条件禁用一些提交按钮。但我找不到这样的财产。

这是我的代码:

active_admin_form_for [:activeadmin, @some_obj], {
    url: {action: 'some_action'}, method: :patch
  } do |f|
    f.inputs 'Some Name' do
      f.li "some html".html_safe
    end

  f.actions do
    f.action :submit, label: 'Update'
  end
end

我厌倦了以下但没有任何效果:

f.action :submit, label: 'Update', disabled: true

f.action :submit, label: 'Update', input_html: {readonly: :true}

f.action :submit, label: 'Update', input_html: {disabled: :true}

f.action :submit, label: 'Update', button_html: {disabled: true}

f.action :submit, label: 'Update', button_html: {readonly: true}

有什么线索吗?

【问题讨论】:

    标签: ruby-on-rails forms ruby-on-rails-5 activeadmin disabled-input


    【解决方案1】:

    f.action 接受 button_html 参数以应用 HTML 属性 - refer

    f.action :submit, label: 'Update', button_html: { disabled: true }
    

    【讨论】:

    • @AhmedSalah 请您检查浏览器上的按钮,看看是否已应用 disabled 属性。我刚刚在我的应用上试了一下,它对我有用。
    • 这是元素的外观<input type="submit" name="commit" value="Update" disabled="disabled" data-disable-with="Update">
    • 对我来说看起来不错。单击该按钮时是否执行了任何操作?
    • 是的,它是上述的表单提交按钮
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 2011-03-12
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    相关资源
    最近更新 更多