sferik/rails_admin — Issue #787: custom field partials
Author: epdp
Created: 2011-10-18 07:49:33+00:00
State: open

I'm using rails admin on several projects, and I made heavy use of the feature of using my own partials for a field just by specifying on config.

Now I started a new project with rails 3.1 and the new rails admin, but I found that rails admin doesn't reach to my partials. I followed the docs and tried several ways to do this, but I couldn't get it to work.

I see in the logs that rails admin renders its own '_form_field.html.haml' partial. When I put my own '_form_field.html.haml' on rails_admin/main, then I see it renders my form_field partial. OK so far. But it never renders my custom '_my_partial.html.haml' (or '_my_partial.html.erb' either) when I put it on rails_admin/main or any other place.

I tried this way:

```
config.model MyModel do
edit do
field :my_field do
partial 'my_partial'
end
end
end
```

But also this way:

```
config.model MyModel do
edit do
field :my_field do
render do
bindings[:view].render :partial => 'my_partial', :locals => {:field => self, :form => bindings[:form]}
end
end
end
end
```

Also tried specifying the full pathname, and using haml and erb partials. None worked. Rails admin always goes for _form_field.html.haml, either its own or my local one. Also I didn't get any errors that could give some clues.

On the list section, 'pretty_value' doesn't seem to work either, but that's maybe unrelated.

What am I doing wrong?