When using form.serialize, it also includes disabled elements. Would it be possible to alter future versions of prototype to not include disabled elements, or have an option not to include disabled elements. Is there a trac(or similar program) for prototype? <!-- Test HTML --?> <form id="myForm"> <input name="one" /> <input name="two" /> <input name="three" /> <input name="four" disabled="disabled" /> </form> <script> alert(Form.serialize($(''myForm''))); </script> <!-- Our Fix --> Form.Element.Methods = { serialize: function(element) { element = $(element); if (element.disabled == true) { return; } var method = element.tagName.toLowerCase(); var parameter = Form.Element.Serializers[method](element); if (parameter) { var key = encodeURIComponent(parameter[0]); if (key.length == 0) return; if (parameter[1].constructor != Array) parameter[1] = [parameter[1]]; return parameter[1].map(function(value) { return key + ''='' + encodeURIComponent(value); }).join(''&''); } }, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Oct-24 07:33 UTC
Re: Prototype: Form.serialize includes disabled elements
On 10/24/06, Zyclops <zyclops-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > When using form.serialize, it also includes disabled elements.This is a bug.> Would > it be possible to alter future versions of prototype to not include > disabled elements, or have an option not to include disabled elements.http://dev.rubyonrails.org/ticket/4586> Is there a trac(or similar program) for prototype?See above. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thomas Fuchs
2006-Oct-24 10:32 UTC
Re: Prototype: Form.serialize includes disabled elements
Btw, just applied the patch to Prototype trunk, see http://dev.rubyonrails.org/changeset/5354 -Thomas Am 24.10.2006 um 09:33 schrieb Martin Bialasinski:> > On 10/24/06, Zyclops <zyclops-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> When using form.serialize, it also includes disabled elements. > > This is a bug. > >> Would >> it be possible to alter future versions of prototype to not include >> disabled elements, or have an option not to include disabled >> elements. > > http://dev.rubyonrails.org/ticket/4586 > >> Is there a trac(or similar program) for prototype? > > See above. > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Colin Mollenhour
2006-Oct-24 21:24 UTC
Re: Prototype: Form.serialize includes disabled elements
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Whoa! Why is this a bug? I have code that might break with this change. A better solution I think for backwards compatibility would be to have an extra parameter that defaults to including disabled and if passed "false" will not include disabled elements.<br> <br> Colin<br> <br> Thomas Fuchs wrote: <blockquote cite="mid75981530-04F3-4E3A-A467-805F1C0CD2B7-moWQItti3gBl57MIdRCFDg@public.gmane.org" type="cite"> <pre wrap="">Btw, just applied the patch to Prototype trunk, see <a class="moz-txt-link-freetext" href="http://dev.rubyonrails.org/changeset/5354">http://dev.rubyonrails.org/changeset/5354</a> -Thomas Am 24.10.2006 um 09:33 schrieb Martin Bialasinski: </pre> <blockquote type="cite"> <pre wrap="">On 10/24/06, Zyclops <a class="moz-txt-link-rfc2396E" href="mailto:zyclops-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"><zyclops-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">When using form.serialize, it also includes disabled elements. </pre> </blockquote> <pre wrap="">This is a bug. </pre> <blockquote type="cite"> <pre wrap="">Would it be possible to alter future versions of prototype to not include disabled elements, or have an option not to include disabled elements. </pre> </blockquote> <pre wrap=""><a class="moz-txt-link-freetext" href="http://dev.rubyonrails.org/ticket/4586">http://dev.rubyonrails.org/ticket/4586</a> </pre> <blockquote type="cite"> <pre wrap="">Is there a trac(or similar program) for prototype? </pre> </blockquote> <pre wrap="">See above. </pre> </blockquote> <pre wrap=""><!----> -- Thomas Fuchs wollzelle <a class="moz-txt-link-freetext" href="http://www.wollzelle.com">http://www.wollzelle.com</a> questentier on AIM madrobby on irc.freenode.net <a class="moz-txt-link-freetext" href="http://www.fluxiom.com">http://www.fluxiom.com</a> :: online digital asset management <a class="moz-txt-link-freetext" href="http://script.aculo.us">http://script.aculo.us</a> :: Web 2.0 JavaScript <a class="moz-txt-link-freetext" href="http://mir.aculo.us">http://mir.aculo.us</a> :: Where no web developer has gone before </pre> </blockquote> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
Michael Peters
2006-Oct-24 21:35 UTC
Re: Prototype: Form.serialize includes disabled elements
Colin Mollenhour wrote:> Whoa! Why is this a bug?Because Form.Serialize is supposed to give you back what the browser would submit as the forms data. It''s the same reason that when prototype serializes a select box and uses the <option>''s text as the value instead of the value when the value is the empty string is a bug (#5033). It''s not what browsers are supposed to do. Btw, Thomas, any reason why #5033 isn''t fixed as well? -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Certainly a bug. But I wonder how many others have accidently allowed this to occur? Deco On Oct 24, 2006, at 3:35 PM, Michael Peters wrote:> > > > Colin Mollenhour wrote: >> Whoa! Why is this a bug? > > Because Form.Serialize is supposed to give you back what the > browser would > submit as the forms data. It''s the same reason that when prototype > serializes a > select box and uses the <option>''s text as the value instead of the > value when > the value is the empty string is a bug (#5033). It''s not what > browsers are > supposed to do. > > Btw, Thomas, any reason why #5033 isn''t fixed as well? > > -- > Michael Peters > Developer > Plus Three, LP > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Oct-25 07:52 UTC
Re: Prototype: Form.serialize includes disabled elements
Hey Michael, Michael Peters a écrit :> Btw, Thomas, any reason why #5033 isn''t fixed as well?I''m not Thomas, but I certainly checked this out and ended up uploading a patch with a comprehensive unit test. The patch suggested in the ticket doesn''t work, btw, as the DOM object (HTMLOptionElement) will *always* feature a ''value'' property, regardless of its being HTML-specified or not. Now, from experience, Thomas is pretty reactive on committing tested patches that he figures are good enough. So far, I''ve been lucky with that :-) Monitor this ticket or the Edge RSS feed, and maybe you''ll see the trunk being updated with this patch in the near future. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Oct-25 08:23 UTC
Re: Prototype: Form.serialize includes disabled elements
On 10/24/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote:> Btw, just applied the patch to Prototype trunk, see > http://dev.rubyonrails.org/changeset/5354Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---