File tree 2 files changed +69
-0
lines changed
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ const validate = (values) => {
27
27
errors . password = 'Required' ;
28
28
}
29
29
30
+ if ( ! values . isAgreeTerms ) {
31
+ errors . isAgreeTerms = 'Required' ;
32
+ }
33
+
30
34
if ( configs . recaptcha && ! values . recaptcha ) {
31
35
errors . recaptcha = 'Required' ;
32
36
}
@@ -100,6 +104,30 @@ class RegisterForm extends Component {
100
104
type = "password"
101
105
placeholder = "Password"
102
106
/>
107
+ < Field
108
+ label = "Skills"
109
+ name = "skills"
110
+ component = { FormField }
111
+ type = "checkboxes"
112
+ style = { { float : 'left' , paddingRight : 20 } }
113
+ options = { [ {
114
+ label : 'Nodejs' ,
115
+ value : 'NODEJS' ,
116
+ } , {
117
+ label : 'Reactjs' ,
118
+ value : 'REACTJS' ,
119
+ } , {
120
+ label : 'Redux' ,
121
+ value : 'REDUX' ,
122
+ } ] }
123
+ />
124
+ < Field
125
+ label = " "
126
+ name = "isAgreeTerms"
127
+ component = { FormField }
128
+ type = "checkbox"
129
+ text = { < span > I agree the < a href = "#" > terms</ a > </ span > }
130
+ />
103
131
< Field
104
132
label = " "
105
133
name = "recaptcha"
Original file line number Diff line number Diff line change @@ -82,6 +82,47 @@ let BsFormField = ({
82
82
< pre > Recaptcha is disabled</ pre >
83
83
) ;
84
84
/* eslint-enable */
85
+ } else if ( type === 'checkbox' ) {
86
+ formControl = (
87
+ < div className = "checkbox" >
88
+ < label >
89
+ < input
90
+ type = "checkbox"
91
+ { ...input }
92
+ { ...rest }
93
+ /> { text }
94
+ </ label >
95
+ </ div >
96
+ ) ;
97
+ } else if ( type === 'checkboxes' ) {
98
+ // ref:
99
+ // - <https://github.com/erikras/redux-form/issues/1037>
100
+ formControl = (
101
+ options . map ( ( option , index ) => (
102
+ < div className = "checkbox" key = { option . value } { ...rest } >
103
+ < label >
104
+ < input
105
+ type = "checkbox"
106
+ name = { `${ input . name } [${ index } ]` }
107
+ value = { option . value }
108
+ checked = { input . value . indexOf ( option . value ) !== - 1 }
109
+ onChange = { event => {
110
+ let newValue = [ ...input . value ] ;
111
+
112
+ if ( event . target . checked ) {
113
+ newValue . push ( option . value ) ;
114
+ } else {
115
+ newValue . splice ( newValue . indexOf ( option . value ) , 1 ) ;
116
+ }
117
+
118
+ return input . onChange ( newValue ) ;
119
+ } }
120
+ />
121
+ { option . label }
122
+ </ label >
123
+ </ div >
124
+ ) )
125
+ ) ;
85
126
} else if ( type === 'radiobutton' ) {
86
127
// ref: <https://github.com/erikras/redux-form/issues/1857#issuecomment-249890206>
87
128
formControl = (
You can’t perform that action at this time.
0 commit comments