material ui - Select all checkbox redux form -
i want check/ uncheck checkboxes moment select check can't make work. i'm using material-ui components , redux-form. plan grab checkall field value using formvalueselector api , set checkbox , b value based of that. tried using value prop no luck still.
import react 'react'; import { connect } 'react-redux'; import { field, reduxform, formvalueselector } 'redux-form'; import { checkbox } 'redux-form-material-ui'; let form = (props) => { return ( <form> <field name="checkall" id="checkall" label="check all" component={ checkbox } /> <field name="a" label="a" component={ checkbox } checked={ props.checkall } /> <field name="b" label="b" component={ checkbox } checked={ props.checkall } /> </form> ); }; form = reduxform({ form: 'form' })(addreturnmodal); // decorate connect read form values const selector = formvalueselector('form'); // <-- same form name form = connect( (state) => { const checkall = selector(state, 'checkall'); return { checkall }; } )(form); export default form;
you use change
method. from docs:
change(field:string, value:any) : function
changes value of field in redux store. bound action creator, returns nothing.
the solution see loop on list of checkboxes , call change(checkboxname, value)
on them.
Comments
Post a Comment