Skip to content
Merged
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
174 changes: 58 additions & 116 deletions __tests__/__snapshots__/factory.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -195,123 +195,65 @@ exports[`factory:definitions 1`] = `
class="cxd-Combo-itemInner"
>
<div
class="cxd-Form cxd-Form--normal cxd-Combo-form"
novalidate=""
class="cxd-Alert cxd-Alert--danger"
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField"
>
<span>
combo 1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
name="key"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField"
>
<span>
combo 2
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
name="value"
placeholder=""
size="10"
type="text"
value="ref value"
/>
</div>
</div>
<div
class="cxd-Remark cxd-Form-remark"
>
<span
class="cxd-Remark-icon"
>
<icon-mock
classname=" icon-warning-mark"
icon="warning-mark"
/>
</span>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField"
>
<span>
children
</span>
</span>
</span>
</label>
<div
class="cxd-Remark cxd-Form-remark"
>
<span
class="cxd-Remark-icon"
>
<icon-mock
classname=" icon-warning-mark"
icon="warning-mark"
/>
</span>
</div>
</div>
<p>
Error: 不允许在表单及表单按钮组中直接嵌套表单
</p>
<p>
Path:
page/body/0/form/1/combo/multiple/0/form
</p>
<pre>
<code>
{
"type": "form",
"body": [
{
"label": "combo 1",
"type": "input-text",
"name": "key"
},
{
"type": "input-text",
"name": "value",
"value": "ref value",
"remark": "通过&lt;code&gt;\\\\$ref&lt;/code&gt;引入的组件",
"label": "combo 2"
},
{
"type": "combo",
"multiple": true,
"multiLine": true,
"remark": "&lt;code&gt;combo&lt;/code&gt;中的子项引入自身,实现嵌套的效果",
"controls": [
{
"label": "combo 1",
"type": "text",
"name": "key"
},
{
"label": "combo 2",
"name": "value",
"$ref": "aa"
},
{
"name": "children",
"label": "children",
"$ref": "bb"
}
],
"name": "children",
"label": "children"
}
],
"wrapperComponent": "div",
"wrapWithPanel": false,
"mode": "normal",
"className": "cxd-Combo-form"
}
</code>
</pre>
</div>
</div>
<a
Expand Down
Binary file added dump.rdb
Binary file not shown.
21 changes: 19 additions & 2 deletions src/renderers/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
import {ActionSchema} from '../Action';
import {ButtonGroupControlSchema} from './ButtonGroupSelect';
import {DialogSchemaBase} from '../Dialog';
import Alert from '../../components/Alert2';

export interface FormSchemaHorizontal {
left?: number;
Expand Down Expand Up @@ -1493,6 +1494,8 @@ export default class Form extends React.Component<FormProps, object> {

render() {
const {
$path,
$schema,
wrapWithPanel,
render,
title,
Expand All @@ -1507,15 +1510,29 @@ export default class Form extends React.Component<FormProps, object> {
affixFooter,
lazyLoad,
translate: __,
footer
footer,
formStore
} = this.props;

// trace(true);
// console.log('Form');

let body: JSX.Element = this.renderBody();

if (wrapWithPanel) {
// 表单组件限制
const isFormInFormActions: boolean = /panel\/action\/form$/.test($path);
// props有formStore 说明是嵌套表单 || 不允许在表单的按钮组中再直接套表单
if (formStore || isFormInFormActions) {
body = (
<Alert level="danger">
<p>Error: 不允许在表单及表单按钮组中直接嵌套表单</p>
<p>Path: {$path}</p>
<pre>
<code>{JSON.stringify($schema, null, 2)}</code>
</pre>
</Alert>
);
} else if (wrapWithPanel) {
body = render(
'body',
{
Expand Down