英文:
SelectInput resettable does not get focus / display validate erros
问题
以下是代码的翻译部分:
<ReferenceInput
label={label}
reference={reference}
sort={byTranslatedAscendingNameSort}
source={source}
>
<SelectInput
optionText={`name_${locale}`}
resettable={true}
source="id"
validate={required()}
/>
</ReferenceInput>
After clicking on the reset cross, values are reset and focus is not on the component.
No validate errors are display until component get and lose focus.
SelectInput and SimpleForm validate detect that the value is undefined after resetting, so errors object is set and contains values.
But those are not display until component get and lose focus.
英文:
The following TSX create a React-Admin 4.8.3 SelectInput with a cross that reset values on click.
<ReferenceInput
label={label}
reference={reference}
sort={byTranslatedAscendingNameSort}
source={source}
>
<SelectInput
optionText={`name_${locale}`}
resettable={true}
source="id"
validate={required()}
/>
</ReferenceInput>
After clicking on the reset cross, values are reset and focus is not on the component.
No validate errors are display until component get and lose focus.
SelectInput and SimpleForm validate detect that the value is undefined after resetting, so errors object is set and contains values.
But those are not display until component get and lose focus.
答案1
得分: 0
验证策略可自定义以适用于表单:验证模式,以下是策略的描述:props 模式。例如,可以尝试以下方式:
<SimpleForm
mode="onChange"
reValidateMode="onChange"
...
>
英文:
Validation strategy is customizable for the form: Validation Mode , here is a description of the strategies: props mode. Try for example like this:
<SimpleForm
mode="onChange"
reValidateMode="onChange"
...
>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论