Form_for with divs and fieldsets => stupid


#1

If I do this:

+============================================+

<% form_for :item, :url => { :controller => 'inventory', :action => 'create' } do |f| %> <%= render :partial => 'item_form', :locals => { :f => f } %> <%= submit_tag "Add" %> <% end %>
+============================================+

I get:

+============================================+

Item Qty Year

+============================================+

I don’t get why the form shows up outside the div and fieldset. If I
move them inside the form_for block everything works as expected.
This behavior seems really strange. Is there are reason why it is
this way, or is this a bug?


Amos K.
A. King Software Development and Consulting, L.C.
http://dirtyInformation.com

Looking for something to do? Visit http://ImThere.com


#2

Something’s going wrong because the form tag is not being generated at
all. I’m surprised there’s not an error though. The only thing pops
out at me is the fact that you aren’t passing an object to it.
Typically form_for is called like:

form_for :item, @item, :url => …

Where :item is the name, and @item provides the values for form
persistence.

On 6/5/07, Amos K. removed_email_address@domain.invalid wrote:

<% end %>
move them inside the form_for block everything works as expected. >


Gabe da Silveira
http://darwinweb.net


#3

I don’t claim to know why this is happening, but what happens when
you move the form_for into the partial?

Also, shouldn’t you have fieldset inside your form_for?

<%= render :partial => 'item_form', :locals => { :f => f } %>

_item_form.rhtml

 <% form_for :item, :url => { :controller => 'inventory', :action

=> ‘create’ } do |f| %>

   <%= submit_tag "Add" %>
 <% end %>


James M.


#4

I moved the div and the fieldset inside the form_for and it works. I
just don’t know why when I put the tags outside it doesn’t get
generated in the right place. I just want to know if there is a
reason for this behavior. I also don’t know why a form tag wasn’t
created. I never tried to submit anything when the form was
displaying outside the fieldset.

Gabe: You only need to pass an object in if the form is going to be
pre-populated. At least that is my understanding.

There is some refactoring being done. The divs and fieldsets and
form_fors are being moved to the partial.

On Jun 5, 10:39 pm, James M. removed_email_address@domain.invalid


#5

Wait, if you move the div and fieldset inside the form_for the form
tags are being generated correctly? Or just the order comes out
correct? The latter makes perfect sense, but the former would be
exceedingly strange.

On Jun 6, 8:44 am, “removed_email_address@domain.invalid” removed_email_address@domain.invalid


#6

If I put the div and fieldset inside the form_for everything is
correct. The form fields are inside the fieldset which in turn is
inside the div, and everything forks great. If I place it as about
everything shows up out of order. I’m using Rails 1.2.3 and Ruby
1.8.6.

On 6/6/07, dasil003 removed_email_address@domain.invalid wrote:

generated in the right place. I just want to know if there is a
On Jun 5, 10:39 pm, James M. removed_email_address@domain.invalid

<%form_for:item, :url => { :controller => 'inventory', :action

+============================================+
type=“text”>
+============================================+

Looking for something to do? Visithttp://ImThere.com


Amos K.
A. King Software Development and Consulting, L.C.
http://dirtyInformation.com

Looking for something to do? Visit http://ImThere.com