mirror of
https://github.com/zhigang1992/form-render.git
synced 2026-06-13 01:08:14 +08:00
readOnly mode stop showing validation text
This commit is contained in:
@@ -43,8 +43,8 @@ function getBasicProps(settings, materials) {
|
||||
displayType,
|
||||
showDescIcon,
|
||||
showValidate,
|
||||
formData,
|
||||
readOnly, // 添加全局控制只读模式
|
||||
formData,
|
||||
} = settings;
|
||||
// 目前做了处理的`uiSchema`参数
|
||||
const {
|
||||
@@ -100,8 +100,9 @@ function getBasicProps(settings, materials) {
|
||||
{
|
||||
...subSchema,
|
||||
column,
|
||||
showDescIcon,
|
||||
displayType,
|
||||
showDescIcon,
|
||||
showValidate,
|
||||
readOnly,
|
||||
formData,
|
||||
},
|
||||
|
||||
23
src/index.js
23
src/index.js
@@ -25,9 +25,24 @@ function renderField(schema, fields, events) {
|
||||
}
|
||||
|
||||
// 在顶层将 propsSchema 和 uiSchema 合并,便于后续处理。 也可直接传入合并的 schema
|
||||
const Wrapper = ({ schema, propsSchema = {}, uiSchema = {}, ...rest }) => {
|
||||
const Wrapper = ({
|
||||
schema,
|
||||
propsSchema = {},
|
||||
uiSchema = {},
|
||||
readOnly,
|
||||
showValidate,
|
||||
...rest
|
||||
}) => {
|
||||
const _schema = schema ? schema : combineSchema(propsSchema, uiSchema);
|
||||
return <FormRender {...rest} schema={_schema} />;
|
||||
|
||||
return (
|
||||
<FormRender
|
||||
readOnly={readOnly}
|
||||
showValidate={!readOnly && showValidate} // 预览模式下不展示校验
|
||||
{...rest}
|
||||
schema={_schema}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
class FormRender extends React.Component {
|
||||
@@ -82,9 +97,7 @@ class FormRender extends React.Component {
|
||||
!isDeepEqual(nextProps.schema, schema) ||
|
||||
!isDeepEqual(Object.keys(nextProps.formData), Object.keys(formData))
|
||||
) {
|
||||
setTimeout(() => {
|
||||
this.needUpdateForm();
|
||||
}, 0);
|
||||
setTimeout(this.needUpdateForm, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user