Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
36dfe304
Commit
36dfe304
authored
Oct 21, 2017
by
杨奕
Committed by
GitHub
Oct 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form: add clearValidate (#7623)
* Form: add clearValidate * remove dup attrs
parent
c3cf3f23
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
18 deletions
+98
-18
examples/docs/en-US/form.md
examples/docs/en-US/form.md
+42
-7
examples/docs/zh-CN/form.md
examples/docs/zh-CN/form.md
+42
-7
packages/form/src/form-item.vue
packages/form/src/form-item.vue
+9
-1
packages/form/src/form.vue
packages/form/src/form.vue
+5
-0
packages/input/src/input.vue
packages/input/src/input.vue
+0
-3
No files found.
examples/docs/en-US/form.md
View file @
36dfe304
...
@@ -47,6 +47,16 @@
...
@@ -47,6 +47,16 @@
resource: '',
resource: '',
desc: ''
desc: ''
},
},
sizeForm: {
name: '',
region: '',
date1: '',
date2: '',
delivery: false,
type:
[]
,
resource: '',
desc: ''
},
formInline: {
formInline: {
user: '',
user: '',
region: ''
region: ''
...
@@ -745,33 +755,33 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
...
@@ -745,33 +755,33 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
::: demo Still you can fine tune each component's
`size`
if you don't want that component to inherit its size from From or FormIten.
::: demo Still you can fine tune each component's
`size`
if you don't want that component to inherit its size from From or FormIten.
```
html
```
html
<el-form
ref=
"form"
:model=
"
f
orm"
label-width=
"120px"
size=
"mini"
>
<el-form
ref=
"form"
:model=
"
sizeF
orm"
label-width=
"120px"
size=
"mini"
>
<el-form-item
label=
"Activity name"
>
<el-form-item
label=
"Activity name"
>
<el-input
v-model=
"
f
orm.name"
></el-input>
<el-input
v-model=
"
sizeF
orm.name"
></el-input>
</el-form-item>
</el-form-item>
<el-form-item
label=
"Activity zone"
>
<el-form-item
label=
"Activity zone"
>
<el-select
v-model=
"
f
orm.region"
placeholder=
"please select your zone"
>
<el-select
v-model=
"
sizeF
orm.region"
placeholder=
"please select your zone"
>
<el-option
label=
"Zone one"
value=
"shanghai"
></el-option>
<el-option
label=
"Zone one"
value=
"shanghai"
></el-option>
<el-option
label=
"Zone two"
value=
"beijing"
></el-option>
<el-option
label=
"Zone two"
value=
"beijing"
></el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
label=
"Activity time"
>
<el-form-item
label=
"Activity time"
>
<el-col
:span=
"11"
>
<el-col
:span=
"11"
>
<el-date-picker
type=
"date"
placeholder=
"Pick a date"
v-model=
"
f
orm.date1"
style=
"width: 100%;"
></el-date-picker>
<el-date-picker
type=
"date"
placeholder=
"Pick a date"
v-model=
"
sizeF
orm.date1"
style=
"width: 100%;"
></el-date-picker>
</el-col>
</el-col>
<el-col
class=
"line"
:span=
"2"
>
-
</el-col>
<el-col
class=
"line"
:span=
"2"
>
-
</el-col>
<el-col
:span=
"11"
>
<el-col
:span=
"11"
>
<el-time-picker
type=
"fixed-time"
placeholder=
"Pick a time"
v-model=
"
f
orm.date2"
style=
"width: 100%;"
></el-time-picker>
<el-time-picker
type=
"fixed-time"
placeholder=
"Pick a time"
v-model=
"
sizeF
orm.date2"
style=
"width: 100%;"
></el-time-picker>
</el-col>
</el-col>
</el-form-item>
</el-form-item>
<el-form-item
label=
"Activity type"
>
<el-form-item
label=
"Activity type"
>
<el-checkbox-group
v-model=
"
f
orm.type"
>
<el-checkbox-group
v-model=
"
sizeF
orm.type"
>
<el-checkbox-button
label=
"Online activities"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"Online activities"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"Promotion activities"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"Promotion activities"
name=
"type"
></el-checkbox-button>
</el-checkbox-group>
</el-checkbox-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"Resources"
>
<el-form-item
label=
"Resources"
>
<el-radio-group
v-model=
"
f
orm.resource"
size=
"medium"
>
<el-radio-group
v-model=
"
sizeF
orm.resource"
size=
"medium"
>
<el-radio
border
label=
"Sponsor"
></el-radio>
<el-radio
border
label=
"Sponsor"
></el-radio>
<el-radio
border
label=
"Venue"
></el-radio>
<el-radio
border
label=
"Venue"
></el-radio>
</el-radio-group>
</el-radio-group>
...
@@ -781,6 +791,30 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
...
@@ -781,6 +791,30 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
<el-button>
Cancel
</el-button>
<el-button>
Cancel
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<script>
export
default
{
data
()
{
return
{
sizeForm
:
{
name
:
''
,
region
:
''
,
date1
:
''
,
date2
:
''
,
delivery
:
false
,
type
:
[],
resource
:
''
,
desc
:
''
}
};
},
methods
:
{
onSubmit
()
{
console
.
log
(
'
submit!
'
);
}
}
};
</script>
```
```
:::
:::
...
@@ -806,6 +840,7 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
...
@@ -806,6 +840,7 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
| validate | the method to validate the whole form. Returns a promise if callback is omitted | Function(callback: Function(boolean)) |
| validate | the method to validate the whole form. Returns a promise if callback is omitted | Function(callback: Function(boolean)) |
| validateField | the method to validate a certain form item | Function(prop: string, callback: Function(errorMessage: string)) |
| validateField | the method to validate a certain form item | Function(prop: string, callback: Function(errorMessage: string)) |
| resetFields | reset all the fields and remove validation result | — |
| resetFields | reset all the fields and remove validation result | — |
| clearValidate | clear validation message for all fields | -
### Form-Item Attributes
### Form-Item Attributes
...
...
examples/docs/zh-CN/form.md
View file @
36dfe304
...
@@ -47,6 +47,16 @@
...
@@ -47,6 +47,16 @@
resource: '',
resource: '',
desc: ''
desc: ''
},
},
sizeForm: {
name: '',
region: '',
date1: '',
date2: '',
delivery: false,
type:
[]
,
resource: '',
desc: ''
},
formInline: {
formInline: {
user: '',
user: '',
region: ''
region: ''
...
@@ -734,34 +744,34 @@
...
@@ -734,34 +744,34 @@
::: demo 如果希望某个表单项或某个表单组件的尺寸不同于 Form 上的
`size`
属性,直接为这个表单项或表单组件设置自己的
`size`
即可。
::: demo 如果希望某个表单项或某个表单组件的尺寸不同于 Form 上的
`size`
属性,直接为这个表单项或表单组件设置自己的
`size`
即可。
```
html
```
html
<el-form
ref=
"form"
:model=
"
f
orm"
label-width=
"80px"
size=
"mini"
>
<el-form
ref=
"form"
:model=
"
sizeF
orm"
label-width=
"80px"
size=
"mini"
>
<el-form-item
label=
"活动名称"
>
<el-form-item
label=
"活动名称"
>
<el-input
v-model=
"
f
orm.name"
></el-input>
<el-input
v-model=
"
sizeF
orm.name"
></el-input>
</el-form-item>
</el-form-item>
<el-form-item
label=
"活动区域"
>
<el-form-item
label=
"活动区域"
>
<el-select
v-model=
"
f
orm.region"
placeholder=
"请选择活动区域"
>
<el-select
v-model=
"
sizeF
orm.region"
placeholder=
"请选择活动区域"
>
<el-option
label=
"区域一"
value=
"shanghai"
></el-option>
<el-option
label=
"区域一"
value=
"shanghai"
></el-option>
<el-option
label=
"区域二"
value=
"beijing"
></el-option>
<el-option
label=
"区域二"
value=
"beijing"
></el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
label=
"活动时间"
>
<el-form-item
label=
"活动时间"
>
<el-col
:span=
"11"
>
<el-col
:span=
"11"
>
<el-date-picker
type=
"date"
placeholder=
"选择日期"
v-model=
"
f
orm.date1"
style=
"width: 100%;"
></el-date-picker>
<el-date-picker
type=
"date"
placeholder=
"选择日期"
v-model=
"
sizeF
orm.date1"
style=
"width: 100%;"
></el-date-picker>
</el-col>
</el-col>
<el-col
class=
"line"
:span=
"2"
>
-
</el-col>
<el-col
class=
"line"
:span=
"2"
>
-
</el-col>
<el-col
:span=
"11"
>
<el-col
:span=
"11"
>
<el-time-picker
type=
"fixed-time"
placeholder=
"选择时间"
v-model=
"
f
orm.date2"
style=
"width: 100%;"
></el-time-picker>
<el-time-picker
type=
"fixed-time"
placeholder=
"选择时间"
v-model=
"
sizeF
orm.date2"
style=
"width: 100%;"
></el-time-picker>
</el-col>
</el-col>
</el-form-item>
</el-form-item>
<el-form-item
label=
"活动性质"
>
<el-form-item
label=
"活动性质"
>
<el-checkbox-group
v-model=
"
f
orm.type"
>
<el-checkbox-group
v-model=
"
sizeF
orm.type"
>
<el-checkbox-button
label=
"美食/餐厅线上活动"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"美食/餐厅线上活动"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"地推活动"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"地推活动"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"线下主题活动"
name=
"type"
></el-checkbox-button>
<el-checkbox-button
label=
"线下主题活动"
name=
"type"
></el-checkbox-button>
</el-checkbox-group>
</el-checkbox-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"特殊资源"
>
<el-form-item
label=
"特殊资源"
>
<el-radio-group
v-model=
"
f
orm.resource"
size=
"medium"
>
<el-radio-group
v-model=
"
sizeF
orm.resource"
size=
"medium"
>
<el-radio
border
label=
"线上品牌商赞助"
></el-radio>
<el-radio
border
label=
"线上品牌商赞助"
></el-radio>
<el-radio
border
label=
"线下场地免费"
></el-radio>
<el-radio
border
label=
"线下场地免费"
></el-radio>
</el-radio-group>
</el-radio-group>
...
@@ -771,6 +781,30 @@
...
@@ -771,6 +781,30 @@
<el-button>
取消
</el-button>
<el-button>
取消
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<script>
export
default
{
data
()
{
return
{
sizeForm
:
{
name
:
''
,
region
:
''
,
date1
:
''
,
date2
:
''
,
delivery
:
false
,
type
:
[],
resource
:
''
,
desc
:
''
}
};
},
methods
:
{
onSubmit
()
{
console
.
log
(
'
submit!
'
);
}
}
};
</script>
```
```
:::
:::
...
@@ -796,6 +830,7 @@
...
@@ -796,6 +830,7 @@
| validate | 对整个表单进行校验的方法。若不传入回调函数,则会返回一个 promise | Function(callback: Function(boolean))
| validate | 对整个表单进行校验的方法。若不传入回调函数,则会返回一个 promise | Function(callback: Function(boolean))
| validateField | 对部分表单字段进行校验的方法 | Function(prop: string, callback: Function(errorMessage: string))
| validateField | 对部分表单字段进行校验的方法 | Function(prop: string, callback: Function(errorMessage: string))
| resetFields | 对整个表单进行重置,将所有字段值重置为初始值并移除校验结果 | -
| resetFields | 对整个表单进行重置,将所有字段值重置为初始值并移除校验结果 | -
| clearValidate | 移除整个表单的校验结果 | -
### Form-Item Attributes
### Form-Item Attributes
...
...
packages/form/src/form-item.vue
View file @
36dfe304
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
},
},
sizeClass ? 'el-form-item--' + sizeClass : ''
sizeClass ? 'el-form-item--' + sizeClass : ''
]">
]">
<label
:for=
"
prop
"
class=
"el-form-item__label"
v-bind:style=
"labelStyle"
v-if=
"label || $slots.label"
>
<label
:for=
"
labelFor
"
class=
"el-form-item__label"
v-bind:style=
"labelStyle"
v-if=
"label || $slots.label"
>
<slot
name=
"label"
>
{{
label
+
form
.
labelSuffix
}}
</slot>
<slot
name=
"label"
>
{{
label
+
form
.
labelSuffix
}}
</slot>
</label>
</label>
<div
class=
"el-form-item__content"
v-bind:style=
"contentStyle"
>
<div
class=
"el-form-item__content"
v-bind:style=
"contentStyle"
>
...
@@ -102,6 +102,9 @@
...
@@ -102,6 +102,9 @@
}
}
},
},
computed
:
{
computed
:
{
labelFor
()
{
return
this
.
for
||
this
.
prop
;
},
labelStyle
()
{
labelStyle
()
{
var
ret
=
{};
var
ret
=
{};
if
(
this
.
form
.
labelPosition
===
'
top
'
)
return
ret
;
if
(
this
.
form
.
labelPosition
===
'
top
'
)
return
ret
;
...
@@ -207,6 +210,11 @@
...
@@ -207,6 +210,11 @@
callback
(
this
.
validateMessage
);
callback
(
this
.
validateMessage
);
});
});
},
},
clearValidate
()
{
this
.
validateState
=
''
;
this
.
validateMessage
=
''
;
this
.
validateDisabled
=
false
;
},
resetField
()
{
resetField
()
{
this
.
validateState
=
''
;
this
.
validateState
=
''
;
this
.
validateMessage
=
''
;
this
.
validateMessage
=
''
;
...
...
packages/form/src/form.vue
View file @
36dfe304
...
@@ -70,6 +70,11 @@
...
@@ -70,6 +70,11 @@
field
.
resetField
();
field
.
resetField
();
});
});
},
},
clearValidate
()
{
this
.
fields
.
forEach
(
field
=>
{
field
.
clearValidate
();
});
},
validate
(
callback
)
{
validate
(
callback
)
{
if
(
!
this
.
model
)
{
if
(
!
this
.
model
)
{
console
.
warn
(
'
[Element Warn][Form]model is required for validate to work!
'
);
console
.
warn
(
'
[Element Warn][Form]model is required for validate to work!
'
);
...
...
packages/input/src/input.vue
View file @
36dfe304
...
@@ -106,7 +106,6 @@
...
@@ -106,7 +106,6 @@
placeholder
:
String
,
placeholder
:
String
,
size
:
String
,
size
:
String
,
resize
:
String
,
resize
:
String
,
icon
:
String
,
name
:
String
,
name
:
String
,
form
:
String
,
form
:
String
,
id
:
String
,
id
:
String
,
...
@@ -115,7 +114,6 @@
...
@@ -115,7 +114,6 @@
readonly
:
Boolean
,
readonly
:
Boolean
,
autofocus
:
Boolean
,
autofocus
:
Boolean
,
disabled
:
Boolean
,
disabled
:
Boolean
,
onIconClick
:
Function
,
type
:
{
type
:
{
type
:
String
,
type
:
String
,
default
:
'
text
'
default
:
'
text
'
...
@@ -139,7 +137,6 @@
...
@@ -139,7 +137,6 @@
type
:
Boolean
,
type
:
Boolean
,
default
:
true
default
:
true
},
},
onIconClick
:
Function
,
suffixIcon
:
String
,
suffixIcon
:
String
,
prefixIcon
:
String
,
prefixIcon
:
String
,
label
:
String
label
:
String
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment