I am building a module for SugarCRM that will be used by many people. Early on I ran into a probelm when saving data with PHP losing part of the POST, I learned that the problem was caused by the PHP INI Setting for max_input_vars
Once I increased the value set for max_input_vars
, everything worked perfect again.
I was able to set the max_input_vars
value with an .htaccess
file. I have ready that you cannot set this value with the PHP function ini_set()
My major concern is this module will be used on many different servers as it will be used by many people.
I need to code a solution that will require the user to do nothing and still have my module continue to function correctly.
On another post a user had recommended that I change my HTML Form which already saved this data using a jQuery AJAX POST to my backend PHP script.
He says that I should change it to save the data by s ending a JSON object to my PHP backend script instead of the large number of POST Vars.
Does anyone else see this as a good solution?
Here is my current frontend code that handles the SAVE now....
function ajaxSaveTasks(){
window.unsavedChanges = false;
// Display a message to the user that we are Saving
ajaxStatus.showStatus('Saving Task Changes');
var url = "index.php?module=apoll_Web_Projects"; // the script where you handle the form post.
//SUGAR.ajaxUI.showLoadingPanel();
jQuery('#project_tasks').showLoading(showLoadingSettings);
$.ajax({
type: "POST",
url: url,
data: $("#editTasksForm").serialize(), // serializes the form's elements.
success: function(data)
{
//alert(data); // show server response
//SUGAR.ajaxUI.hideLoadingPanel();
hideTaskUnSavedChangesHeaderBar()
jQuery('#project_tasks').hideLoading();
}
});
ajaxStatus.hideStatus();
};
The other user mentions that if this code is modified to POST my FORM using JSON instead that I can get around the max_input_vars
issue altogether. If I understand correctly, he is saying that instead of my 1,000+ Form POST variables being sent, it will send it as 1 variable which holds a huge giant JSON string instead...does that sound right?
If this sounds like it could be a good solution, then could someone show me how I might achieve this?
My FORM is a page for Mass Adding and Editing Project Task Database records, so it can be very large and have hundreds of Task records to update in the database.
In the code above you can see that it simply runs $("#editTasksForm").serialize()
to get all the Form fields.