mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
fix:表单使用增加两个限制条件 (#2562)
Co-authored-by: dqc <qianchuan.deng@gmail.com>
This commit is contained in:
parent
e1c9f44fa5
commit
78233c14eb
@ -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": "通过<code>\\\\$ref</code>引入的组件",
|
||||
"label": "combo 2"
|
||||
},
|
||||
{
|
||||
"type": "combo",
|
||||
"multiple": true,
|
||||
"multiLine": true,
|
||||
"remark": "<code>combo</code>中的子项引入自身,实现嵌套的效果",
|
||||
"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
|
||||
|
@ -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;
|
||||
@ -1493,6 +1494,8 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
$path,
|
||||
$schema,
|
||||
wrapWithPanel,
|
||||
render,
|
||||
title,
|
||||
@ -1507,7 +1510,8 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
affixFooter,
|
||||
lazyLoad,
|
||||
translate: __,
|
||||
footer
|
||||
footer,
|
||||
formStore
|
||||
} = this.props;
|
||||
|
||||
// trace(true);
|
||||
@ -1515,7 +1519,20 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
|
||||
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',
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user