I have a edit form in Active Admin. I need some field as read only.
My current edit page is like
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
Please help.
The trick is to use "object". Here is how you should code it:
Try to add
, :disabled => true
for address input field.For a cleaner form definition within your ActiveAdmin.register{} block you may as well want to define a "readonly" input type to be used within active admin using formtastic:
Form block syntax is for activeadmin version 1.0.0.pre at 0becbef0918a.
How about this?
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:
in your CSS active_admin.css
I was facing the same issue and tried using
:disabled
but it did not solve my problem as I wantedfield
value to be included inparams
object while sending it to the server. When you mark aform input
as:input_html => {:disabled => true}
, it does not include this field value inparams
. So, instead I used:input_html => {:readonly => true}
which solved both of my problems:edit
params
I hope this will help.