11import React from 'react' ;
22import PropTypes from 'prop-types' ;
3- import { append , contains , without } from 'ramda' ;
3+ import { append , includes , without } from 'ramda' ;
44import classNames from 'classnames' ;
55import CustomInput from '../../private/CustomInput' ;
66
@@ -18,7 +18,7 @@ import CustomInput from '../../private/CustomInput';
1818 * https://getbootstrap.com/docs/4.4/components/forms/#checkboxes-and-radios-1
1919 */
2020const Checklist = props => {
21- const { className, id, options, style, key, loading_state} = props ;
21+ const { className, id, options, style, key, loading_state, name } = props ;
2222
2323 const listItem = option => {
2424 const {
@@ -36,7 +36,7 @@ const Checklist = props => {
3636 switch : switches
3737 } = props ;
3838
39- const checked = contains ( option . value , value ) ;
39+ const checked = includes ( option . value , value ) ;
4040
4141 const mergedLabelStyle = checked
4242 ? { ...labelStyle , ...labelCheckedStyle }
@@ -48,6 +48,8 @@ const Checklist = props => {
4848 return (
4949 < CustomInput
5050 id = { inputId }
51+ name = { name }
52+ value = { option . value }
5153 labelId = { option . label_id }
5254 checked = { checked }
5355 className = { inputClassName }
@@ -62,7 +64,7 @@ const Checklist = props => {
6264 inline = { inline }
6365 onChange = { ( ) => {
6466 let newValue ;
65- if ( contains ( option . value , value ) ) {
67+ if ( includes ( option . value , value ) ) {
6668 newValue = without ( [ option . value ] , value ) ;
6769 } else {
6870 newValue = append ( option . value , value ) ;
@@ -84,14 +86,16 @@ const Checklist = props => {
8486 >
8587 < input
8688 id = { inputId }
89+ name = { name }
90+ value = { option . value }
8791 checked = { checked }
8892 className = { classNames ( 'form-check-input' , inputClassName ) }
8993 disabled = { Boolean ( option . disabled ) }
9094 style = { inputStyle }
9195 type = "checkbox"
9296 onChange = { ( ) => {
9397 let newValue ;
94- if ( contains ( option . value , value ) ) {
98+ if ( includes ( option . value , value ) ) {
9599 newValue = without ( [ option . value ] , value ) ;
96100 } else {
97101 newValue = append ( option . value , value ) ;
@@ -300,7 +304,12 @@ Checklist.propTypes = {
300304 * local: window.localStorage, data is kept after the browser quit.
301305 * session: window.sessionStorage, data is cleared once the browser quit.
302306 */
303- persistence_type : PropTypes . oneOf ( [ 'local' , 'session' , 'memory' ] )
307+ persistence_type : PropTypes . oneOf ( [ 'local' , 'session' , 'memory' ] ) ,
308+
309+ /**
310+ * The name of the control, which is submitted with the form data.
311+ */
312+ name : PropTypes . string
304313} ;
305314
306315Checklist . defaultProps = {
0 commit comments