submit disabled fields
Why not simply enable all the disabled input fields right before the submission using .removeAttr()
and .submit()
.
$('#my_form').submit(function(){
$("#my_form :disabled").removeAttr('disabled');
});
You can make your fields readonly, this will disallow changes to the value of your controls.
Edit: You could easily write a "serializeDisabled" function, iterating over the disabled form elements which have a name attribute and using the jQuery.param function at the end, to generate the serialized string:
(function ($) {
$.fn.serializeDisabled = function () {
var obj = {};
$(':disabled[name]', this).each(function () {
obj[this.name] = $(this).val();
});
return $.param(obj);
}
})(jQuery);
OK... perhaps I didn't ask my question clearly enough... but the answer I was looking for is here:
http://docs.jquery.com/Plugins:Forms#.val.28.29_becomes_.fieldValue.28.29
I mentioned ajaxSubmit() in my question, which comes from the jQuery Form plugin... and inside that plug-in there is a method called fieldValue() which accepts a parameter called "successful". If you pass in "true" then the plug-in only returns what the W3C defines as "successful" controls (which excludes disabled controls). but if you set it to false, then it will get all values, regardless of W3C definition.
I knew this was possible, since the entire submission is controlled by the plug-in and has nothing to do with the HTML standards/definition... I was just asking to see if this option was already available in this plug-in or other plugins. It is available in this plugin, although the default behavior is to act like a standard HTML submit
//jQuery('#container :input').serializeAll()
(function($j) {
$j.fn.serializeDisabled=function(){
var obj={};
$j(this).filter(':input:disabled').each(function(index,domElem){
var $this=$j(domElem);
obj[domElem.name]=$this.val();
});
return $j.param(obj);
};
$j.fn.serializeAll=function(){
$this=$j(this);
return $this.filter(':input:enabled').serialize()+'&'+$this.serializeDisabled();
};
})(jQuery);