From a953e7e423ea0dd42cfe0de7ef6ad8e7e5f56368 Mon Sep 17 00:00:00 2001 From: Rustam Mamadaminov Date: Mon, 24 Sep 2018 20:45:42 +0500 Subject: [PATCH] Fixes #15791: Added a warning when the form names conflict --- framework/CHANGELOG.md | 1 + framework/assets/yii.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 84f54624e4..bd5a667620 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.16 under development ------------------------ +- Bug #15791: Added a warning when the form names conflict (s1lver, rustamwin) - Enh #16151: `ActiveQuery::getTableNameAndAlias()` is now protected (s1lver) - Bug #16657: Ensure widgets after run event result contains the result of the rendered widget (AdeAttwood) - Bug #14230: Fixed `itemsOptions` ignored in `checkBoxList` (s1lver) diff --git a/framework/assets/yii.js b/framework/assets/yii.js index 51a01c6791..fd38b02dce 100644 --- a/framework/assets/yii.js +++ b/framework/assets/yii.js @@ -57,7 +57,7 @@ window.yii = (function ($) { * The selector for clickable elements that need to support confirmation and form submission. */ clickableSelector: 'a, button, input[type="submit"], input[type="button"], input[type="reset"], ' + - 'input[type="image"]', + 'input[type="image"]', /** * The selector for changeable elements that need to support confirmation and form submission. */ @@ -160,7 +160,18 @@ window.yii = (function ($) { pjax = $e.data('pjax'), usePjax = pjax !== undefined && pjax !== 0 && $.support.pjax, pjaxContainer, - pjaxOptions = {}; + pjaxOptions = {}, + conflictParams = ['submit', 'reset', 'elements', 'length', 'name', 'acceptCharset', + 'action', 'enctype', 'method', 'target']; + + // Forms and their child elements should not use input names or ids that conflict with properties of a form, + // such as submit, length, or method. + $.each(conflictParams, function (index, param) { + if (areValidParams && params.hasOwnProperty(param)) { + console.error("Parameter name '" + param + "' conflicts with a same named form property. " + + "Please use another name."); + } + }); if (usePjax) { pjaxContainer = $e.data('pjax-container');