Skip to content

Commit

Permalink
Merge pull request #1119 from Tithugues/help4319
Browse files Browse the repository at this point in the history
Add message to warn the user if a form has too many fields.
  • Loading branch information
lem9 committed Mar 30, 2014
2 parents 356f306 + eac47b0 commit 5c0b541
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/ajax.js
Expand Up @@ -291,6 +291,7 @@ var AJAX = {
"<div id='page_content'>" + data.message + "</div>"
);
PMA_highlightSQL($('#page_content'));
checkNumberOfFields();
}

if (data._selflink) {
Expand Down
2 changes: 2 additions & 0 deletions js/common.js
Expand Up @@ -11,6 +11,8 @@ $(function () {
event.preventDefault();
PMA_querywindow.focus();
});

checkNumberOfFields();
});

/**
Expand Down
20 changes: 20 additions & 0 deletions js/functions.js
Expand Up @@ -4112,3 +4112,23 @@ function PMA_formatDateTime(date, seconds) {
}
);
}

/**
* Check than forms have less fields than max allowed by PHP.
*/
function checkNumberOfFields() {
if (typeof maxInputVars === 'undefined') {
return false;
}
$('form').each(function() {
var nbInputs = $(this).find(':input').length;
if (nbInputs > maxInputVars) {
var warning = $.sprintf(PMA_messages.strTooManyInputs, maxInputVars);
PMA_ajaxShowMessage(warning);
return false;
}
return true;
});

return true;
}
9 changes: 9 additions & 0 deletions js/messages.php
Expand Up @@ -402,6 +402,12 @@
$js_messages['strTimeOutError'] = __(
"Your export is incomplete, due to a low execution time limit at the PHP level!"
);

$js_messages['strTooManyInputs'] = __(
"Warning: a form on this page has more than %d fields and could not be "
. "processed."
);

echo "var PMA_messages = new Array();\n";
foreach ($js_messages as $name => $js_message) {
PMA_printJsValue("PMA_messages['" . $name . "']", $js_message);
Expand All @@ -419,6 +425,9 @@

echo "var mysql_doc_template = '" . PMA_Util::getMySQLDocuURL('%s') . "';\n";

//Max input vars allowed by PHP.
echo 'var maxInputVars = ' . ini_get('max_input_vars') . ';';

echo "if ($.datepicker) {\n";
/* l10n: Display text for calendar close link */
PMA_printJsValue("$.datepicker.regional['']['closeText']", __('Done'));
Expand Down

0 comments on commit 5c0b541

Please sign in to comment.