Created
October 16, 2008 01:29
-
-
Save subtleGradient/17048 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // TODO: Remove this once it's added to MooTools code | |
| Element.implement({ | |
| toFormHash: function(){ | |
| var formHash = $H(); | |
| this.getElements('input, select, textarea', true).each(function(el){ | |
| if (!el.name || el.disabled) return; | |
| var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){ | |
| return opt.value; | |
| }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value; | |
| $splat(value).each(function(val){ | |
| if (typeof val != 'undefined') | |
| formHash.set(el.name, val); | |
| }); | |
| }); | |
| return formHash; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment