I have a field for which rails_admin
generates a textfield, but I'd like it to use a <select>
tag instead. I customized the field like this, in my initializer:
RailsAdmin.config do |config|
config.model User do
update do
field :state do
partial "user_state_partial"
end
end
end
end
I've tested it, and it works. The problem is, by doing like this ( I tried with an edit block too ), the only field left, is the one I'm customizing. Is there any way of telling rails_admin to just assume the defaults for the other fields?
A better (and shorter) solution is to use the 'configure' syntax instead of 'field'. By using configure, rails_admin will use the defaults for all other values.
So for example, using the following:
RailsAdmin.config do |config|
config.model User do
update do
configure :state do
partial "user_state_partial"
end
end
end
end
...will allow RailsAdmin to use the stated partial for :state, but it will use defaults for all other fields.
More information can be found at: Rails Admin wiki
Once you have defined one field, you have to define all fields that you want to use. The default is all fields.
RailsAdmin.config do |config|
config.model User do
update do
field :name
field :surname
field :state do
partial "user_state_partial"
end
end
end
end
The current docs say you can, like this:
field :name do
# snipped specific configuration for name attribute
end
include_all_fields # all other default fields will be added after, conveniently
exclude_fields :created_at # but you still can remove fields
...but it still removes association subforms. (You can add back belongs_to items with "field :association_id" (not "field :association") but I'm not sure how to add back has_* subforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With