On 9/25/07, Frederick Cheung <[EMAIL PROTECTED]> wrote:
> I've been thinking of instead allowing
>
> <% form_for :person, @person, :url => {...} do |f| %>
> ...
> <%= f.partial 'form' %>
> ...
> <% end %>
>
> f.partial would be exactly the same as the previous snippet, just
> making the form builder available in the partial without the hassle
> of :locals => {'f' => f}
Looks great!
> the one thing I'm not sure about is how you pick the name under which
> the form builder should appear in the partial.
Well, we could leave a simple "f" by default. Most people are probably
used to that, right?
> Ideally f.partial 'form' would give you something sensible, but I'm
> not sure how you would pick such a default
Why not something like:
-- environment.rb
Rails::Initializer.run do |config|
config.action_view.form_builder_name = :f
end
And even:
config.action_view.form_builder = :labelled_form_builder
To always have form_for give you a custom builder.
> f.partial 'form', :name => 'f' would work, but then it's almost as
> awkward as :locals => {'f' => f}
We could leave that option for the very rare case where you want to
override the local variable name on a specific partial...
> Any ideas (or is this one just stupid ?) ?
I wonder if this is the reason why the scaffold_resource generator
doesn't deal with form partials like scaffold did? (ie the lack of a
nice way to do it).
Overall, +1!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---