优化部分代码,增加微信公众号模板
This commit is contained in:
@@ -141,13 +141,19 @@ class BaseController
|
||||
$result = [];
|
||||
foreach ($checkFields as $fieldName) {
|
||||
$checkValue = $data[$fieldName] ?? '';
|
||||
if (is_array($checkValue) && !empty($checkValue)) {
|
||||
$result[$fieldName] = $checkValue;
|
||||
if (is_array($checkValue)) {
|
||||
// 数组值单独处理:非空才收;空数组按「跳过」(与 GF 版一致),
|
||||
// 且绝不对数组做 strval,避免触发 "Array to string conversion" 警告
|
||||
if (!empty($checkValue)) {
|
||||
$result[$fieldName] = $checkValue;
|
||||
}
|
||||
} else {
|
||||
if (mb_strlen(strval($checkValue)) <= 0 && !in_array($fieldName, $this->notRequest)) {
|
||||
$requiredFields[] = $fieldName;
|
||||
} else {
|
||||
if (!empty($checkValue) || $checkValue === 0) {
|
||||
// 用字符串长度判断是否有值,避免 !empty 把合法的 0 / "0" 误当空丢弃
|
||||
// (HTTP 参数皆为字符串,status=0 会传成 "0",原写法会导致状态无法写入/改回启用)
|
||||
if (mb_strlen(strval($checkValue)) > 0) {
|
||||
$result[$fieldName] = $checkValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user