Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: form-render支持仅渲染FormItem项便于与已存在的表单做融入 #1594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions packages/form-render/src/form-core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const FormCore:FC<FRProps> = (props) => {
className,
validateTrigger,
antdVersion,
onlyFormItem
} = transformProps({ ...props, ...schemProps });

useEffect(() => {
Expand Down Expand Up @@ -211,8 +212,19 @@ const FormCore:FC<FRProps> = (props) => {
</Button>
);
}

const renderFormItem = () => {
return (
<Row gutter={displayType === "row" ? 16 : 24}>
<RenderCore schema={schema} />
{operateExtra}
</Row>
);
};

return (
return onlyFormItem
? renderFormItem()
: (
<Form
className={classNames('fr-form', { [className]: !!className } )}
labelWrap={true}
Expand All @@ -223,10 +235,7 @@ const FormCore:FC<FRProps> = (props) => {
onFinishFailed={handleFinishFailed}
onValuesChange={handleValuesChange}
>
<Row gutter={displayType === 'row' ? 16 : 24}>
<RenderCore schema={schema} />
{operateExtra}
</Row>
{renderFormItem()}
{schema && !!footer && (
<Row gutter={displayType === 'row' ? 16 : 24}>
<Col span={24 / column}>
Expand Down
4 changes: 3 additions & 1 deletion packages/form-render/src/models/transformProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const transformProps = (props: any) => {
className,
validateTrigger,
antdVersion,
onlyFormItem,
...otherProps
} = props;

Expand Down Expand Up @@ -78,7 +79,8 @@ const transformProps = (props: any) => {
maxWidth,
className,
validateTrigger,
antdVersion
antdVersion,
onlyFormItem
};
};

Expand Down