diff --git a/administrator/components/com_categories/views/category/tmpl/edit.php b/administrator/components/com_categories/views/category/tmpl/edit.php
index f2e3cb1a4612b..2b036146175ab 100644
--- a/administrator/components/com_categories/views/category/tmpl/edit.php
+++ b/administrator/components/com_categories/views/category/tmpl/edit.php
@@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'item-form', array('category.apply', 'category.save', 'category.save2new', 'category.save2copy'));
$app = JFactory::getApplication();
$input = $app->input;
diff --git a/administrator/components/com_config/view/application/tmpl/default.php b/administrator/components/com_config/view/application/tmpl/default.php
index 3ffef1d492810..9ce4c37cface7 100644
--- a/administrator/components/com_config/view/application/tmpl/default.php
+++ b/administrator/components/com_config/view/application/tmpl/default.php
@@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'application-form', array('config.save.application.apply', 'config.save.application.save'));
JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbutton = function(task)
diff --git a/administrator/components/com_config/view/component/tmpl/default.php b/administrator/components/com_config/view/component/tmpl/default.php
index 6a099bcc1af1e..4b1f04c861308 100644
--- a/administrator/components/com_config/view/component/tmpl/default.php
+++ b/administrator/components/com_config/view/component/tmpl/default.php
@@ -16,6 +16,7 @@
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'component-form', array('config.save.component.apply', 'config.save.component.save'));
JFactory::getDocument()->addScriptDeclaration(
'
diff --git a/administrator/components/com_content/views/article/tmpl/edit.php b/administrator/components/com_content/views/article/tmpl/edit.php
index e22e7a0e2590a..8772c40c4927f 100644
--- a/administrator/components/com_content/views/article/tmpl/edit.php
+++ b/administrator/components/com_content/views/article/tmpl/edit.php
@@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'item-form', array('article.apply', 'article.save', 'article.save2new', 'article.save2copy'));
$this->configFieldsets = array('editorConfig');
$this->hiddenFieldsets = array('basic-limited');
diff --git a/administrator/components/com_menus/views/item/tmpl/edit.php b/administrator/components/com_menus/views/item/tmpl/edit.php
index 73445628f22eb..53f27bad8042a 100644
--- a/administrator/components/com_menus/views/item/tmpl/edit.php
+++ b/administrator/components/com_menus/views/item/tmpl/edit.php
@@ -16,6 +16,7 @@
JHtml::_('behavior.tabstate');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'item-form', array('item.apply', 'item.save', 'item.save2new', 'item.save2copy'));
JText::script('ERROR');
JText::script('JGLOBAL_VALIDATION_FORM_FAILED');
diff --git a/administrator/components/com_modules/views/module/tmpl/edit.php b/administrator/components/com_modules/views/module/tmpl/edit.php
index 905b13ddbe6c2..9096bdcc0ba4e 100644
--- a/administrator/components/com_modules/views/module/tmpl/edit.php
+++ b/administrator/components/com_modules/views/module/tmpl/edit.php
@@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.combobox');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'module-form', array('module.apply', 'module.save', 'module.save2new', 'module.save2copy'));
$hasContent = empty($this->item->module) || isset($this->item->xml->customContent);
$hasContentFieldName = "content";
diff --git a/administrator/components/com_plugins/views/plugin/tmpl/edit.php b/administrator/components/com_plugins/views/plugin/tmpl/edit.php
index e7e1d11f2ed5f..5d119a202fcc4 100644
--- a/administrator/components/com_plugins/views/plugin/tmpl/edit.php
+++ b/administrator/components/com_plugins/views/plugin/tmpl/edit.php
@@ -13,6 +13,8 @@
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'style-form', array('plugin.apply', 'plugin.save'));
+
$this->fieldsets = $this->form->getFieldsets('params');
JFactory::getDocument()->addScriptDeclaration("
diff --git a/administrator/components/com_users/views/user/tmpl/edit.php b/administrator/components/com_users/views/user/tmpl/edit.php
index bcd1d16dfe70f..38cb71f8121b0 100644
--- a/administrator/components/com_users/views/user/tmpl/edit.php
+++ b/administrator/components/com_users/views/user/tmpl/edit.php
@@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('behavior.inputlimittest', 'user-form', array('user.apply', 'user.save', 'user.save2new'));
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
diff --git a/administrator/language/en-GB/en-GB.ini b/administrator/language/en-GB/en-GB.ini
index 70f1a68797190..aa9b236f30750 100644
--- a/administrator/language/en-GB/en-GB.ini
+++ b/administrator/language/en-GB/en-GB.ini
@@ -167,6 +167,8 @@ JERROR_NOLOGIN_BLOCKED="Login denied! Your account has either been blocked or yo
JERROR_SENDING_EMAIL="Email could not be sent."
JERROR_SESSION_STARTUP="Error initialising the session."
JERROR_SAVE_FAILED="Could not save data. Error: %s"
+JERROR_MAXVARS_REACHED="Your PHP configuration has an input limit of %s variables and your website is close to that limit or has reached that limit and is using approximately %s.
This will create issues making changes to your website.
Please contact your hosting provider and ask them to increase the limit of the PHP setting max_input_vars."
+JERROR_MAXVARS_NOSUBMIT="You cannot submit the form until the limit is changed."
JFIELD_ACCESS_DESC="The access level group that is allowed to view this item."
JFIELD_ACCESS_LABEL="Access"
diff --git a/administrator/templates/hathor/html/com_categories/category/edit.php b/administrator/templates/hathor/html/com_categories/category/edit.php
index ce8029278985d..90873ff4a5ae4 100644
--- a/administrator/templates/hathor/html/com_categories/category/edit.php
+++ b/administrator/templates/hathor/html/com_categories/category/edit.php
@@ -18,6 +18,7 @@
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidator');
+JHtml::_('behavior.inputlimittest', 'item-form', array('category.apply', 'category.save', 'category.save2new', 'category.save2copy'));
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
diff --git a/administrator/templates/hathor/html/com_config/application/default.php b/administrator/templates/hathor/html/com_config/application/default.php
index 9de28a7bb0a76..af7de334823a8 100644
--- a/administrator/templates/hathor/html/com_config/application/default.php
+++ b/administrator/templates/hathor/html/com_config/application/default.php
@@ -11,6 +11,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.switcher');
+JHtml::_('behavior.inputlimittest', 'application-form', array('config.save.application.apply', 'config.save.application.save'));
// Load submenu template, using element id 'submenu' as needed by behavior.switcher
$this->document->setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu');
diff --git a/administrator/templates/hathor/html/com_config/component/default.php b/administrator/templates/hathor/html/com_config/component/default.php
index 9e6350ea2e28d..4c87181a1d82d 100644
--- a/administrator/templates/hathor/html/com_config/component/default.php
+++ b/administrator/templates/hathor/html/com_config/component/default.php
@@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('bootstrap.framework');
+JHtml::_('behavior.inputlimittest', 'component-form', array('config.save.component.apply', 'config.save.component.save'));
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
diff --git a/administrator/templates/hathor/html/com_content/article/edit.php b/administrator/templates/hathor/html/com_content/article/edit.php
index 42a1b795bdb3b..2d32d713925d6 100644
--- a/administrator/templates/hathor/html/com_content/article/edit.php
+++ b/administrator/templates/hathor/html/com_content/article/edit.php
@@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
+JHtml::_('behavior.inputlimittest', 'item-form', array('article.apply', 'article.save', 'article.save2new', 'article.save2copy'));
// Create shortcut to parameters.
$params = $this->state->get('params');
diff --git a/administrator/templates/hathor/html/com_menus/item/edit.php b/administrator/templates/hathor/html/com_menus/item/edit.php
index b7b64b60f71e9..473831a1303f7 100644
--- a/administrator/templates/hathor/html/com_menus/item/edit.php
+++ b/administrator/templates/hathor/html/com_menus/item/edit.php
@@ -15,6 +15,7 @@
JHtml::_('behavior.framework');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.modal');
+JHtml::_('behavior.inputlimittest', 'item-form', array('item.apply', 'item.save', 'item.save2new', 'item.save2copy'));
$assoc = JLanguageAssociations::isEnabled();
diff --git a/administrator/templates/hathor/html/com_modules/module/edit.php b/administrator/templates/hathor/html/com_modules/module/edit.php
index ab7d22e86d6e2..56eb9fdbbc14f 100644
--- a/administrator/templates/hathor/html/com_modules/module/edit.php
+++ b/administrator/templates/hathor/html/com_modules/module/edit.php
@@ -13,6 +13,8 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.combobox');
+JHtml::_('behavior.inputlimittest', 'module-form', array('module.apply', 'module.save', 'module.save2new', 'module.save2copy'));
+
$hasContent = empty($this->item->module) || $this->item->module == 'custom' || $this->item->module == 'mod_custom';
$script = "Joomla.submitbutton = function(task)
diff --git a/administrator/templates/hathor/html/com_plugins/plugin/edit.php b/administrator/templates/hathor/html/com_plugins/plugin/edit.php
index 9a7f3a3f78a76..3aacc21d12103 100644
--- a/administrator/templates/hathor/html/com_plugins/plugin/edit.php
+++ b/administrator/templates/hathor/html/com_plugins/plugin/edit.php
@@ -12,6 +12,7 @@
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.formvalidator');
+JHtml::_('behavior.inputlimittest', 'style-form', array('plugin.apply', 'plugin.save'));
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
diff --git a/administrator/templates/hathor/html/com_users/user/edit.php b/administrator/templates/hathor/html/com_users/user/edit.php
index ac2814e5185a3..8a542f59edb9c 100644
--- a/administrator/templates/hathor/html/com_users/user/edit.php
+++ b/administrator/templates/hathor/html/com_users/user/edit.php
@@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
+JHtml::_('behavior.inputlimittest', 'user-form', array('user.apply', 'user.save', 'user.save2new'));
// Get the form fieldsets.
$fieldsets = $this->form->getFieldsets();
diff --git a/libraries/cms/html/behavior.php b/libraries/cms/html/behavior.php
index 1c07cf22c1fbc..fc2f6ae1ba966 100644
--- a/libraries/cms/html/behavior.php
+++ b/libraries/cms/html/behavior.php
@@ -900,4 +900,70 @@ public static function tabstate()
JHtml::_('script', 'system/tabs-state.js', false, true);
self::$loaded[__METHOD__] = true;
}
+
+ /**
+ * Add script for checks the setting of php max_input_vars and notify user
+ *
+ * @param string $formid The id of the form that will be used for test
+ * @param array $preventTasks Tasks that will be prevented when limit is reached
+ *
+ * @return void
+ *
+ * @since 3.5
+ */
+ public static function inputLimitTest($formid = 'adminForm', $preventTasks = array())
+ {
+ if (isset(self::$loaded[__METHOD__][$formid]))
+ {
+ return;
+ }
+
+ // Get the request limit from the PHP configiration
+ $suhosinPostVars = (int) ini_get('suhosin.post.max_vars');
+ $suhosinReqVars = (int) ini_get('suhosin.request.max_vars');
+ $maxinputvars = (int) ini_get('max_input_vars');
+
+ if ($suhosinPostVars || $suhosinReqVars)
+ {
+ // Take the minimum value but not a zero
+ $maxinputvars = min(array_filter(array($suhosinPostVars, $suhosinReqVars)));
+ }
+ elseif (!$maxinputvars)
+ {
+ // Server do not tell us his secrets
+ return;
+ }
+
+ static::core();
+ JHtml::_('jquery.framework');
+ JText::script('JERROR_MAXVARS_REACHED');
+ JText::script('JERROR_MAXVARS_NOSUBMIT');
+
+ JFactory::getDocument()->addScriptDeclaration('
+ jQuery(window).load(function(){
+ var form = document.getElementById("' . $formid . '"),
+ tasks = ' . json_encode($preventTasks) . ', msgs = {},
+ limit = ' . $maxinputvars . ', msg, type, reached, near;
+ if (!form) return;
+ reached = form.length >= limit;
+ near = form.length/limit > 0.8;
+ if (!reached && !near) return;
+ type = reached ? "error" : "warning";
+ msg = Joomla.JText._("JERROR_MAXVARS_REACHED");
+ msg = msg.replace("%s", limit).replace("%s", form.length);
+ msgs[type] = [msg];
+ Joomla.renderMessages(msgs);
+ if (reached) {
+ jQuery(form).on("submit", function(){
+ if (tasks.indexOf(this.task.value) !== -1) {
+ Joomla.renderMessages({"error":[msg, Joomla.JText._("JERROR_MAXVARS_NOSUBMIT")]});
+ return false;
+ }
+ });
+ }
+ });
+ ');
+
+ self::$loaded[__METHOD__][$formid] = true;
+ }
}