Skip to content

Commit

Permalink
fix: Combo配置flat且成员配置必填后校验无法通过问题 (#9027)
Browse files Browse the repository at this point in the history
  • Loading branch information
lurunze1226 authored Dec 5, 2023
1 parent 088431d commit 53674f8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/amis/src/renderers/Form/Combo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ export default class ComboControl extends React.Component<ComboProps> {
nullable,
value: rawValue,
translate: __,
store
store,
flat
} = this.props;
const value = this.getValueAsArray();
const minLength = this.resolveVariableProps(this.props, 'minLength');
Expand Down Expand Up @@ -940,16 +941,19 @@ export default class ComboControl extends React.Component<ComboProps> {
let valid = false;
for (let formitem of form.items) {
const cloned: IFormItemStore = cloneModel(formitem);
let value: any = getVariable(values, formitem.name, false);
/** 开启flat后subForm的值会挂在字段"flat"下,所以不需要基于 name 取值 */
let derivedValue: any = flat
? values
: getVariable(values, formitem.name, false);

if (formitem.extraName) {
value = [
if (formitem.extraName && !flat) {
derivedValue = [
getVariable(values, formitem.name, false),
getVariable(values, formitem.extraName, false)
];
}

cloned.changeTmpValue(value, 'dataChanged');
cloned.changeTmpValue(derivedValue, 'dataChanged');
valid = await cloned.validate(values);
destroyModel(cloned);
if (valid === false) {
Expand Down

0 comments on commit 53674f8

Please sign in to comment.