From 83503e5e8aecfcd99d9ef401019960912a8c4efb Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:04:46 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat(form):=20=E7=9B=B8=E5=90=8C=20na?= =?UTF-8?q?me=20=E7=9A=84=20checkbox=EF=BC=8C=E5=B0=86=E5=80=BC=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E4=B8=BA=E6=95=B0=E7=BB=84=20(#2428)"=20(#24?= =?UTF-8?q?43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c7452c788ad9116144c74f95aea8c6c9bb5d65a3. --- src/modules/form.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index a2ba090e..0831bd7a 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -113,7 +113,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ type = itemElem[0].type; // 如果为复选框 - if(itemElem.length === 1 && type === 'checkbox'){ + if(type === 'checkbox'){ itemElem[0].checked = value; } else if(type === 'radio') { // 如果为单选框 itemElem.each(function(){ @@ -154,12 +154,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ } if(/^(checkbox|radio)$/.test(item.type) && !item.checked) return; // 复选框和单选框未选中,不记录字段 - var n = init_name || item.name; - var v = othis.val(); - // 相同 name 的字段,将值合并到数组 - field[n] = field[n] === undefined ? v - : $.isArray(field[n]) ? field[n].concat(v) - : [field[n], v]; + field[init_name || item.name] = othis.val(); }); return field;