If I do this: +============================================+ <div class="form" id="form" style="display : none;"> <fieldset> <% form_for :item, :url => { :controller => ''inventory'', :action => ''create'' } do |f| %> <%= render :partial => ''item_form'', :locals => { :f => f } %> <%= submit_tag "Add" %> <% end %> </fieldset> </div> +============================================+ I get: +============================================+ <div style="display: none;" id="form" class="form"> <fieldset> </fieldset> </div> <p> <label for="item_description"> Item </label> <input size="20" name="item[description]" id="item_description" type="text"> <label for="item_on_hand"> Qty </label> <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> <label for="item_year"> Year </label> <input value="2007" size="4" name="item[year]" id="item_year" disabled="disabled" type="text"> </p> +============================================+ 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 King A. King Software Development and Consulting, L.C. http://dirtyInformation.com -- Looking for something to do? Visit http://ImThere.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 King <amos.l.king-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > If I do this: > > +============================================+ > <div class="form" id="form" style="display : none;"> > <fieldset> > <% form_for :item, :url => { :controller => ''inventory'', :action > => ''create'' } do |f| %> > <%= render :partial => ''item_form'', :locals => { :f => f } %> > <%= submit_tag "Add" %> > <% end %> > </fieldset> > </div> > +============================================+ > > I get: > > +============================================+ > <div style="display: none;" id="form" class="form"> > <fieldset> > </fieldset> > </div> > > <p> > <label for="item_description"> > Item > </label> > <input size="20" name="item[description]" id="item_description" type="text"> > <label for="item_on_hand"> > Qty > </label> > <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> > <label for="item_year"> > Year > </label> > <input value="2007" size="4" name="item[year]" id="item_year" > disabled="disabled" type="text"> > </p> > +============================================+ > > > > 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 King > A. King Software Development and Consulting, L.C. > http://dirtyInformation.com > -- > Looking for something to do? Visit http://ImThere.com > > > >-- Gabe da Silveira http://darwinweb.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? <div class="form" id="form" style="display : none;"> <fieldset> <%= render :partial => ''item_form'', :locals => { :f => f } %> </fieldset> </div> ---- _item_form.rhtml <% form_for :item, :url => { :controller => ''inventory'', :action => ''create'' } do |f| %> <%= submit_tag "Add" %> <% end %> -- James Mitchell On Jun 5, 2007, at 8:52 PM, Amos King wrote:> > If I do this: > > +============================================+ > <div class="form" id="form" style="display : none;"> > <fieldset> > <% form_for :item, :url => { :controller => ''inventory'', :action > => ''create'' } do |f| %> > <%= render :partial => ''item_form'', :locals => { :f => f } %> > <%= submit_tag "Add" %> > <% end %> > </fieldset> > </div> > +============================================+ > > I get: > > +============================================+ > <div style="display: none;" id="form" class="form"> > <fieldset> > </fieldset> > </div> > > <p> > <label for="item_description"> > Item > </label> > <input size="20" name="item[description]" id="item_description" > type="text"> > <label for="item_on_hand"> > Qty > </label> > <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> > <label for="item_year"> > Year > </label> > <input value="2007" size="4" name="item[year]" id="item_year" > disabled="disabled" type="text"> > </p> > +============================================+ > > > > 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 King > A. King Software Development and Consulting, L.C. > http://dirtyInformation.com > -- > Looking for something to do? Visit http://ImThere.com > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Amos.L.King-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-06 14:44 UTC
Re: form_for with divs and fieldsets => stupid
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 Mitchell <edgetechservices....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t claim to know why this is happening, but what happens when > you move theform_forinto the partial? > > Also, shouldn''t you have fieldset inside yourform_for? > > <div class="form" id="form" style="display : none;"> > <fieldset> > <%= render :partial => ''item_form'', :locals => { :f => f } %> > </fieldset> > </div> > > ---- > _item_form.rhtml > > <%form_for:item, :url => { :controller => ''inventory'', :action > => ''create'' } do |f| %> > > <%= submit_tag "Add" %> > <% end %> > > -- > James Mitchell > > On Jun 5, 2007, at 8:52 PM, Amos King wrote: > > > > > If I do this: > > > +============================================+ > > <div class="form" id="form" style="display : none;"> > > <fieldset> > > <%form_for:item, :url => { :controller => ''inventory'', :action > > => ''create'' } do |f| %> > > <%= render :partial => ''item_form'', :locals => { :f => f } %> > > <%= submit_tag "Add" %> > > <% end %> > > </fieldset> > > </div> > > +============================================+ > > > I get: > > > +============================================+ > > <div style="display: none;" id="form" class="form"> > > <fieldset> > > </fieldset> > > </div> > > > <p> > > <label for="item_description"> > > Item > > </label> > > <input size="20" name="item[description]" id="item_description" > > type="text"> > > <label for="item_on_hand"> > > Qty > > </label> > > <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> > > <label for="item_year"> > > Year > > </label> > > <input value="2007" size="4" name="item[year]" id="item_year" > > disabled="disabled" type="text"> > > </p> > > +============================================+ > > > I don''t get why the form shows up outside the div and fieldset. If I > > move them inside theform_forblock everything works as expected. > > This behavior seems really strange. Is there are reason why it is > > this way, or is this a bug? > > > -- > > Amos King > > A. King Software Development and Consulting, L.C. > >http://dirtyInformation.com > > -- > > Looking for something to do? Visithttp://ImThere.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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, "Amos.L.K...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Amos.L.K...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 Mitchell <edgetechservices....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > I don''t claim to know why this is happening, but what happens when > > you move theform_forinto the partial? > > > Also, shouldn''t you have fieldset inside yourform_for? > > > <div class="form" id="form" style="display : none;"> > > <fieldset> > > <%= render :partial => ''item_form'', :locals => { :f => f } %> > > </fieldset> > > </div> > > > ---- > > _item_form.rhtml > > > <%form_for:item, :url => { :controller => ''inventory'', :action > > => ''create'' } do |f| %> > > > <%= submit_tag "Add" %> > > <% end %> > > > -- > > James Mitchell > > > On Jun 5, 2007, at 8:52 PM, Amos King wrote: > > > > If I do this: > > > > +============================================+ > > > <div class="form" id="form" style="display : none;"> > > > <fieldset> > > > <%form_for:item, :url => { :controller => ''inventory'', :action > > > => ''create'' } do |f| %> > > > <%= render :partial => ''item_form'', :locals => { :f => f } %> > > > <%= submit_tag "Add" %> > > > <% end %> > > > </fieldset> > > > </div> > > > +============================================+ > > > > I get: > > > > +============================================+ > > > <div style="display: none;" id="form" class="form"> > > > <fieldset> > > > </fieldset> > > > </div> > > > > <p> > > > <label for="item_description"> > > > Item > > > </label> > > > <input size="20" name="item[description]" id="item_description" > > > type="text"> > > > <label for="item_on_hand"> > > > Qty > > > </label> > > > <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> > > > <label for="item_year"> > > > Year > > > </label> > > > <input value="2007" size="4" name="item[year]" id="item_year" > > > disabled="disabled" type="text"> > > > </p> > > > +============================================+ > > > > I don''t get why the form shows up outside the div and fieldset. If I > > > move them inside theform_forblock everything works as expected. > > > This behavior seems really strange. Is there are reason why it is > > > this way, or is this a bug? > > > > -- > > > Amos King > > > A. King Software Development and Consulting, L.C. > > >http://dirtyInformation.com > > > -- > > > Looking for something to do? Visithttp://ImThere.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 <gabriel.d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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, "Amos.L.K...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Amos.L.K...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > 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 Mitchell <edgetechservices....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > I don''t claim to know why this is happening, but what happens when > > > you move theform_forinto the partial? > > > > > Also, shouldn''t you have fieldset inside yourform_for? > > > > > <div class="form" id="form" style="display : none;"> > > > <fieldset> > > > <%= render :partial => ''item_form'', :locals => { :f => f } %> > > > </fieldset> > > > </div> > > > > > ---- > > > _item_form.rhtml > > > > > <%form_for:item, :url => { :controller => ''inventory'', :action > > > => ''create'' } do |f| %> > > > > > <%= submit_tag "Add" %> > > > <% end %> > > > > > -- > > > James Mitchell > > > > > On Jun 5, 2007, at 8:52 PM, Amos King wrote: > > > > > > If I do this: > > > > > > +============================================+ > > > > <div class="form" id="form" style="display : none;"> > > > > <fieldset> > > > > <%form_for:item, :url => { :controller => ''inventory'', :action > > > > => ''create'' } do |f| %> > > > > <%= render :partial => ''item_form'', :locals => { :f => f } %> > > > > <%= submit_tag "Add" %> > > > > <% end %> > > > > </fieldset> > > > > </div> > > > > +============================================+ > > > > > > I get: > > > > > > +============================================+ > > > > <div style="display: none;" id="form" class="form"> > > > > <fieldset> > > > > </fieldset> > > > > </div> > > > > > > <p> > > > > <label for="item_description"> > > > > Item > > > > </label> > > > > <input size="20" name="item[description]" id="item_description" > > > > type="text"> > > > > <label for="item_on_hand"> > > > > Qty > > > > </label> > > > > <input size="5" name="item[on_hand]" id="item_on_hand" type="text"> > > > > <label for="item_year"> > > > > Year > > > > </label> > > > > <input value="2007" size="4" name="item[year]" id="item_year" > > > > disabled="disabled" type="text"> > > > > </p> > > > > +============================================+ > > > > > > I don''t get why the form shows up outside the div and fieldset. If I > > > > move them inside theform_forblock everything works as expected. > > > > This behavior seems really strange. Is there are reason why it is > > > > this way, or is this a bug? > > > > > > -- > > > > Amos King > > > > A. King Software Development and Consulting, L.C. > > > >http://dirtyInformation.com > > > > -- > > > > Looking for something to do? Visithttp://ImThere.com > > > > >-- Amos King A. King Software Development and Consulting, L.C. http://dirtyInformation.com -- Looking for something to do? Visit http://ImThere.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---