FIeld Names and Dynamic Fields
-
I am a developer edition user.
I need to be able to have static field names. I have a robust system tied to the cpcff_process_data function which reads the $_POST array. If I can’t have static field names, that means I have to make the $_POST array parser different for every form id, which is very difficult.
Instead, for each form, I have tried to use the below code. I can see the inputs being added to the DOM but not coming across in the _POST array. It does not make sense to me that an input I add to the the form does not come across to the server.
var formFieldMapping = {
firstname : ‘fieldname8’,
lastname : ‘fieldname9’,
address : ‘fieldname15’,
city : ‘fieldname32’,
state : ‘fieldname33’,
zip : ‘fieldname34’,
bill : ‘fieldname1’,
email : ‘fieldname12’,
util : ‘fieldname4’,
homeowner : ‘fieldname2’,
shade : ‘fieldname5’,
propertytype : ‘fieldname39’,
submit : ‘fieldname37’
};
var cffForm = jQuery(“form:has(input[name=cp_calculatedfieldsf_id][value=28])”);var submitButton = cffForm.find(‘#’+ formFieldMapping[‘submit’]);
submitButton.click(function() {
Object.keys(formFieldMapping).forEach(function(key, index) {
var fieldval = cffForm.find(‘#’+this[key]).val();
var inp = $(‘<input>’).attr({
type: ‘hidden’,
id: key,
name: key
});
inp.val(fieldval);
inp.appendTo(cffForm);
}, formFieldMapping);
});
- The topic ‘FIeld Names and Dynamic Fields’ is closed to new replies.