fix(payment): 充值商品选项旧字符串值导致假条目且不可删除
- SchemaProvider 读取时 group/repeater 字段忽略非数组旧值(textarea 时代的 字符串),回退默认数组,避免前端按字符渲染出 20+ 条假条目 - AksField group/repeater 渲染改为数组安全视图(非数组一律按空列表) - 充值商品选项默认条数调整为 3 条(PHP 与前端 schema 同步)
This commit is contained in:
@@ -535,7 +535,14 @@ class SchemaProvider {
|
||||
|
||||
$data = $this->collect_defaults($schema);
|
||||
foreach ($this->get_all_fields($schema) as $field) {
|
||||
if (array_key_exists($field['key'], $stored)) {
|
||||
$field_type = (string) ($field['type'] ?? 'text');
|
||||
$has_stored = array_key_exists($field['key'], $stored);
|
||||
// group/repeater 只接受数组;旧标量值(如 textarea 时代的字符串)
|
||||
// 直接忽略并回退默认,避免前端把字符串按字符渲染成大量假条目。
|
||||
if ($has_stored && in_array($field_type, ['group', 'repeater'], true) && !is_array($stored[$field['key']])) {
|
||||
$has_stored = false;
|
||||
}
|
||||
if ($has_stored) {
|
||||
$data[$field['key']] = $stored[$field['key']];
|
||||
}
|
||||
if (($field['sanitize_type'] ?? '') === 'money_decimal' && array_key_exists($field['key'], $data)) {
|
||||
@@ -545,7 +552,7 @@ class SchemaProvider {
|
||||
}
|
||||
}
|
||||
|
||||
$stored_value = array_key_exists($field['key'], $stored) ? $stored[$field['key']] : ($data[$field['key']] ?? '');
|
||||
$stored_value = $has_stored ? $stored[$field['key']] : ($data[$field['key']] ?? '');
|
||||
|
||||
if (!empty($field['secret'])) {
|
||||
$data[$field['key']] = trim((string) $stored_value) !== '' ? '***' : '';
|
||||
|
||||
Reference in New Issue
Block a user