Skip to content

Conversation

@taotecode
Copy link
Contributor

如:编辑/新增内的字段的RadiosControl类型中的options属性,为了方便提前能够预填字段内的选项,可以直接输入json格式的字符串,如[{"label":"\u4fdd\u5bc6","value":0},{"label":"\u7537","value":1},{"label":"\u5973","value":2}],生成代码后即可立即使用。

更改代码:
文件:src/Renderers/BaseRenderer.php
函数:33
代码内容:

if(is_string($value) && is_array(json_decode($value, true)) && (json_last_error() == JSON_ERROR_NONE)){
 $this->amisSchema[$name] = json_decode($value, true);
}else{
 $this->amisSchema[$name] = $value;
}

逻辑说明:
增加针对字符串内容进行json格式判断,如果为json格式,将进行解码并赋值

演示图片:
image

如:编辑/新增内的字段的RadiosControl类型中的options属性,为了方便提前能够预填字段内的选项,可以直接输入json格式的字符串,如“[{"label":"\u4fdd\u5bc6","value":0},{"label":"\u7537","value":1},{"label":"\u5973","value":2}]”,生成代码后即可立即使用。

更改代码:
文件:src/Renderers/BaseRenderer.php
函数:33
代码内容:
if(is_string($value) && is_array(json_decode($value, true)) && (json_last_error() == JSON_ERROR_NONE)){
 $this->amisSchema[$name] = json_decode($value, true);
}else{
 $this->amisSchema[$name] = $value;
}
逻辑说明:
增加针对字符串内容进行json格式判断,如果为json格式,将进行解码并赋值
@slowlyo
Copy link
Owner

slowlyo commented Feb 6, 2024

这么改的话, 可能会影响到其他组件, 情况太过复杂

需要对每个组件的每个属性进行测试, 而且在后续amis的更新中, 说不定某个属性就不好使了~

这个要处理的话, 只能在代码生成器侧处理🤔

src/Support/CodeGenerator/ControllerGenerator.php line: 278 这个位置做判断

@taotecode
Copy link
Contributor Author

这么改的话, 可能会影响到其他组件, 情况太过复杂

需要对每个组件的每个属性进行测试, 而且在后续amis的更新中, 说不定某个属性就不好使了~

这个要处理的话, 只能在代码生成器侧处理🤔

src/Support/CodeGenerator/ControllerGenerator.php line: 278 这个位置做判断

好的,我这边再进行调试修改

如:编辑/新增内的字段的RadiosControl类型中的options属性,为了方便提前能够预填字段内的选项,可以直接输入json格式的字符串,如“[{"label":"\u4fdd\u5bc6","value":0},{"label":"\u7537","value":1},{"label":"\u5973","value":2}]”,生成代码后即可立即使用。

更改代码:
文件:src/Support/CodeGenerator/ControllerGenerator.php
函数:getColumnComponent
行数:281
逻辑说明:
增加针对字符串内容进行json格式判断,如果为json格式,将进行解码并赋值
@taotecode
Copy link
Contributor Author

已做更改
image
实现效果
image

@slowlyo slowlyo merged commit 54dc0d9 into slowlyo:master Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants