diff --git a/src/checkbox-group/index.js b/src/checkbox-group/index.js
index 18e7ecba8..b78a44d76 100644
--- a/src/checkbox-group/index.js
+++ b/src/checkbox-group/index.js
@@ -1,10 +1,11 @@
import { createNamespace } from '../utils';
+import { FieldMixin } from '../mixins/field';
import { ParentMixin } from '../mixins/relation';
const [createComponent, bem] = createNamespace('checkbox-group');
export default createComponent({
- mixins: [ParentMixin('vanCheckbox')],
+ mixins: [ParentMixin('vanCheckbox'), FieldMixin],
props: {
max: [Number, String],
diff --git a/src/checkbox/index.less b/src/checkbox/index.less
index c2edf00fa..64da9abdd 100644
--- a/src/checkbox/index.less
+++ b/src/checkbox/index.less
@@ -15,6 +15,10 @@
cursor: default;
}
+ &--horizontal {
+ margin-right: @padding-sm;
+ }
+
&__icon {
flex: none;
height: 1em;
diff --git a/src/field/index.js b/src/field/index.js
index 908f4a4eb..dc85c7d77 100644
--- a/src/field/index.js
+++ b/src/field/index.js
@@ -118,6 +118,16 @@ export default createComponent({
formValue() {
return this.children ? this.children.value : this.value;
},
+
+ formValueEmpty() {
+ const { formValue } = this;
+
+ if (Array.isArray(formValue)) {
+ return !formValue.length;
+ }
+
+ return !formValue;
+ },
},
methods: {
@@ -144,7 +154,7 @@ export default createComponent({
const messages = [];
this.rules.forEach(rule => {
- if (rule.required && !this.formValue) {
+ if (rule.required && this.formValueEmpty) {
messages.push(rule.message);
}
});
diff --git a/src/form/demo/FieldType.vue b/src/form/demo/FieldType.vue
index 4bbcf2c48..f87243717 100644
--- a/src/form/demo/FieldType.vue
+++ b/src/form/demo/FieldType.vue
@@ -9,6 +9,21 @@
+
+
+
+ {{ $t('checkbox') }} 1
+
+
+ {{ $t('checkbox') }} 2
+
+
+
+
{{ $t('radio') }} 1
@@ -47,6 +62,7 @@ export default {
stepper: '步进器',
checkbox: '复选框',
fieldType: '表单项类型',
+ checkboxGroup: '复选框组',
requireCheckbox: '请勾选复选框',
},
'en-US': {
@@ -58,6 +74,7 @@ export default {
stepper: 'Stepper',
checkbox: 'Checkbox',
fieldType: 'Field Type',
+ checkboxGroup: 'Checkbox Group',
requireCheckbox: 'Checkbox is required',
},
},
@@ -69,6 +86,7 @@ export default {
slider: 50,
stepper: 1,
checkbox: false,
+ checkboxGroup: [],
switchChecked: false,
};
},
diff --git a/src/radio/index.less b/src/radio/index.less
index 1c5bcaa59..241aa7c8a 100644
--- a/src/radio/index.less
+++ b/src/radio/index.less
@@ -16,7 +16,7 @@
}
&--horizontal {
- margin-right: 12px;
+ margin-right: @padding-sm;
}
&__icon {