From a quick look through the meta_row code it looks like an old and
possibly now neglected attempt to dry up the interface. For most
purposes you could probably ignore it and just use form helpers as
usual. In that case the idiom you want is probably either this:
- form_for :player, {...} do |f|
= render :partial => "form", :object => f
or something like
- form_for :player, {...} do |f|
= render :partial => "player_fields", :locals => {:form => f}
either of which would allow you to call FormHelper methods in the
partial with eg
= form.text_field :first_name
If you want to persevere with the meta_row mechanism, the best
approach is probably to have a look at what happens inside admin/
pages_controller (this is in the radiant files, not in your app) for
the definition of rows andapp/views/admin/pages/_meta_row.html.haml
for the way the rows are then displayed in the page-editing view.
There may have been changes since that wiki page was written.
best,
will
> Hi Will,
>
> Thanks for your reply.
> I don't want to open a new form with "form_for" though. That tutorial
> added fields to the pages table. So I want to add fields to the
> already-open form_for :page. That's what the tutorial does, but I
> couldn't find out how to access the variable that holds the "form"
> object for the already-open page form. "self", as mentioned in the
> tutorial, doesn't make sense and doesn't seem to work, either.
Oh, I see. Sorry. In that case you'll probably find the functionality
described under 'Add partial with fields to the page edit view' more
useful if you ignore the meta_row stuff. I don't really know why the
author of that page would choose to use the meta_row mechanism rather
than just calling for a text_field. Even if it worked it would put the
fields inside a <tr>.
>>>> The 2nd problem is that :locals => {:f => self} doesn't seem to
>>>> work.
You're quite right: for that to make sense f should be set to the
fieldset or the form, not the ActionView instance, and I have never
worked out how to get at those in in a newly added partial. I always
end up falling back on the old FormTagHelper syntax and using the
@variable.
Sorry not to be more useful,
will