So I know that you cannot nest forms in HTML as I''ve found out today, but I have a need to do this or get around it. You can see the admin panel I''m building at: juiceboxcommunications.com/admin/subscribers Click on the empty space in one of the table results to fly out complete subscriber data. In there, there''s a submit, I was trying to have a form for each subscriber which submits. I also need a form around the checkboxes though, so I can handle the functions in the right panel such as select all, add selected to category, etc. etc. The trouble is, that in my code involves nesting a form around the checkboxes (which involves nesting around the rest of the results). So I need a faux way to nest forms, or another workable solution if anyone has dealt with this. the code is like this: <% for subscriber in @subscribers %> <%= check_box(''subscriber'', ''checkBox'', :name => ''subscriber_ids[]'', :id => subscriber.id )%> <%= text_field(''subscriber'', ''firstName'', :value => subscriber.firstName ) %> <%= text_field(''subscriber'', ''lastName'', :value => subscriber.lastName ) %> etc. etc. <% end %> If anyone has experience with this, it is much appreciated. Jason -- Posted via ruby-forum.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have a look at *form_remote_tag *that might help On 11/21/06, Jason Pfeifer <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > So I know that you cannot nest forms in HTML as I''ve found out today, > but I have a need to do this or get around it. > > You can see the admin panel I''m building at: > juiceboxcommunications.com/admin/subscribers > > Click on the empty space in one of the table results to fly out > complete subscriber data. > In there, there''s a submit, I was trying to have a form for each > subscriber which submits. > > I also need a form around the checkboxes though, so I can handle the > functions in the right panel such as select all, add selected to > category, etc. etc. > > The trouble is, that in my code involves nesting a form around the > checkboxes (which involves nesting around the rest of the results). So > I need a faux way to nest forms, or another workable solution if anyone > has dealt with this. > > the code is like this: > > <% for subscriber in @subscribers %> > <%= check_box(''subscriber'', ''checkBox'', :name => ''subscriber_ids[]'', > :id => subscriber.id )%> > <%= text_field(''subscriber'', ''firstName'', :value => > subscriber.firstName ) %> > <%= text_field(''subscriber'', ''lastName'', :value => > subscriber.lastName ) %> > etc. > etc. > <% end %> > > If anyone has experience with this, it is much appreciated. > > Jason > > -- > Posted via ruby-forum.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m not really a web developer so I might be missing some potential problems here, but from what I understand, there are many possible ways around the problem: a) Use one form around everything, but have the various Submit buttons rewrite the form''s "action" attribute to redirect the form to different actions or even controllers. Each controller/action then decides, what data from the form is relevant to that particular action and ignores the rest b) Use one form, but have the various Submit buttons set some parameters in a hidden field that your controller can see and decide what the intended action was c) Use multiple forms, but make them not nested in html. You could use some css positioning (and/or javascript if necessary) to make them visually appear in the right places Cheers, Mati -- Posted via ruby-forum.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mati wrote:> I''m not really a web developer so I might be missing some potential > problems here, but from what I understand, there are many possible ways > around the problem: > a) Use one form around everything, but have the various Submit buttons > rewrite the > form''s "action" attribute to redirect the form to different actions or > even controllers. Each controller/action then decides, what data from > the form is relevant to that particular action and ignores the rest > b) Use one form, but have the various Submit buttons set some parameters > in a hidden field that your controller can see and decide what the > intended action was > c) Use multiple forms, but make them not nested in html. You could use > some css positioning (and/or javascript if necessary) to make them > visually appear in the right placesYes. Another way is to dispose of either the outer form or inner set of forms and instead submit that data using submit_to_remote and its :submit parameter. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mati wrote:> c) Use multiple forms, but make them not nested in html. You could use > some css positioning (and/or javascript if necessary) to make them > visually appear in the right placesI would second this. Might be a pain to hack, but I''m not aware of any common way to trick the browser into nesting forms. Although I think you can add form elements without declaring an actual form. You could use javascript to seralize the values into a string, and pass it via AJAX, bypassing any kind of form action. (Or if for some reason, you can''t nest form elements, create a custom graphic checkbox, and use an onClick event to register the true/false value and pass through AJAX). None of these are a particularly pretty solution. I tend to subscribe to the philsophy that if my design attempts to do something that isn''t generally supported or commonly done, it''s probably time to rethink my design. Brute force hacking my way through an HTML/CSS/Javascript problem often results in lots of frustration, and a final product that doesn''t always feel right. -- Posted via ruby-forum.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The solution I am working on right now is duplicating the checkboxes elsewhere on the page in a form that will be hidden. Then, I use javascript onSubmit to pass the values for ''checked'' to the hidden form checkboxes. It is kind of hacky, but so far it looks like it might work - and then I can just submit the duplicate values in a second form not seen by the user. Any comments from people who''ve tried this before are appreciated. The interface is based heavily on javascript so I''m not worried about people that don''t have it turned on, they can''t use the system anyway. The trouble I was having in looking at the remote submit functions, is that I don''t understand how to pass it only the values that I want to update on my controller. I have a controller that is: def update_subscriber { @subscriber = Subscriber.find(params[:id]) If @subscriber.update_attributes # do the action here end } whereas if I have it submit the whole form I''m not a good enough web developer yet to sort through all that data. Or am I making it more complicated than it needs to be? I''ve been known to do that to myself from time to time... Thx, J -- Posted via ruby-forum.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
YIKES!!! this would fall flat without JavaScript enabled! with more and more users on the mobile web, backwards compatibility is more important than ever. On 11/21/06, Mati <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m not really a web developer so I might be missing some potential > problems here, but from what I understand, there are many possible ways > around the problem: > a) Use one form around everything, but have the various Submit buttons > rewrite the > form''s "action" attribute to redirect the form to different actions or > even controllers. Each controller/action then decides, what data from > the form is relevant to that particular action and ignores the rest > b) Use one form, but have the various Submit buttons set some parameters > in a hidden field that your controller can see and decide what the > intended action was > c) Use multiple forms, but make them not nested in html. You could use > some css positioning (and/or javascript if necessary) to make them > visually appear in the right places > > Cheers, > Mati > > -- > Posted via ruby-forum.com. > > > >-- Chris Martin Web Developer Open Source & Web Standards Advocate chriscodes.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The old (and backwards compatible) approach is to use one form. When you receive the parameters, evaluate the value of the submit button that was pressed (it''s value will be the button your user pressed.) Based on this, fire the appropriate method. On 11/21/06, Chris Martin <chriscodes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > YIKES!!! > > this would fall flat without JavaScript enabled! > > with more and more users on the mobile web, backwards compatibility is > more important than ever. > > On 11/21/06, Mati <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > I''m not really a web developer so I might be missing some potential > > problems here, but from what I understand, there are many possible ways > > around the problem: > > a) Use one form around everything, but have the various Submit buttons > > rewrite the > > form''s "action" attribute to redirect the form to different actions or > > even controllers. Each controller/action then decides, what data from > > the form is relevant to that particular action and ignores the rest > > b) Use one form, but have the various Submit buttons set some parameters > > in a hidden field that your controller can see and decide what the > > intended action was > > c) Use multiple forms, but make them not nested in html. You could use > > some css positioning (and/or javascript if necessary) to make them > > visually appear in the right places > > > > Cheers, > > Mati > > > > -- > > Posted via ruby-forum.com. > > > > > > > > > > -- > > Chris Martin > Web Developer > Open Source & Web Standards Advocate > chriscodes.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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---