如何在Active Admin的编辑页面中仅显示值 [英] How to display only the value in edit page in Active Admin

查看:63
本文介绍了如何在Active Admin的编辑页面中仅显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Active Admin中有一个编辑表单。我需要一些字段为只读。

I have a edit form in Active Admin. I need some field as read only.

我当前的编辑页面就像

我需要页面看起来像这样

I need the page look like this

如何做到这一点。我在编辑表单页面上的代码是

How can this be done. My code for the edit form page is like

    form :html => { :enctype => "multipart/form-data" } do |f|  
      f.inputs "Users" do
        f.input :device, :label => 'Device', :as => :select, :collection => DEVICE, :include_blank => false
        f.input :current_address, :label => 'Current Address', :as => :string
      end
    end

请帮助。

推荐答案

如Alex所说,设置为禁用。然后,如果可以使用CSS的语义,则可以使用CSS获得所需的视觉效果。

As Alex said, set to disabled. You could then use css to get the visual you wanted, if you can live with the semantics of that.

语法让我无法使用。

在您的管理表单中:

 f.input :finish_position, input_html: { disabled: true } 

在您的CSS中active_admin.css

in your CSS active_admin.css

input[disabled="disabled"],
input[disabled] {
  background-color: #F4F4F4;
  border: 0px solid #F4F4F4 !important;  
}

这篇关于如何在Active Admin的编辑页面中仅显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆