How to display only the value in edit page in Active Admin

Amal Kumar S picture Amal Kumar S · Oct 3, 2012 · Viewed 17.7k times · Source

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

My current edit page is like

enter image description here

I need the page look like this

enter image description here

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

Please help.

Answer

Will picture Will · Nov 7, 2013

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.

The syntax was slightly different for me to get this to work.

in your admin form:

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

in your CSS active_admin.css

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