Created
March 15, 2014 08:33
-
-
Save Sam152/9563500 to your computer and use it in GitHub Desktop.
This allows you to turn an HTML form into a PHP POST array to make submitting forms in the context of Drupal tests easier.
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
javascript:var $=jQuery;var str="";var nl="\n";$.each($("form"),function(e,t){str+="$"+$(t).attr("id").split("-").join("_")+" = array("+nl;$.each($(t).find("input, select, textarea"),function(e,t){var n=$(t).attr("name");var r=$(t).val().split("'").join("\\'");if(n=="op"||n==""||n=="form_build_id"||n=="form_token"||n=="form_id"){return}str+=" '"+n+"' => '"+r+"',"+nl});str+=");"+nl+nl});console.log(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment