These are chat archives for erikras/redux-form

3rd
Jul 2017
Tobias Lundgren
@lundgren2
Jul 03 2017 00:16
Is it possible to save form data in a db, and then select a customer and then load the form data for this customer? Should I use initialValues and mapStateToProps? Like this:

<Field
                  key={brand._id}
                  name={`brands.${brand._id}`} <--- HERE
                  label={brand.name}
                  value={brand._id}
                  component={renderCheckbox}
                  type="checkbox"
/>

const mapStateToProps = (state) => {
  const selector = formValueSelector('crmform');
  const visittypeValue = selector(state, 'visittype');
  const brandsValue = selector(state, 'brands');
  const formValues = { visittype: visittypeValue, brands: brandsValue };

  return {
    formValues,
    user: state.auth.user,
    crm: state.crm,
    initialValues: {
      visittype: 'Visit',
      edutype: 'Basic',
      brands: state.crm.selectedcustomer ? state.crm.selectedcustomer.brands : {}, <-- HERE
    },
  };
};
Or Schneider
@SchneiderOr
Jul 03 2017 21:17
Hey guys, any help making sync validation appear only when the field is not focused?
(MaterialUI).