foxhound87
1/5/2017 - 1:18 PM

bindField function for mobx-react-form

bindField function for mobx-react-form

export const bindField = (form, field, {error = 'error', value = 'value', floatLabel = false, onChangeFn, onChange = 'onChange', placeholder = 'placeholder'}={}) => ({
  name: form.$(field).name,
  [value]: form.$(field).value,
  [placeholder]: form.$(field).label,
  ...floatLabel === true && {floatingLabelText: form.$(field).label},
  [onChange]: onChangeFn || form.$(field).sync,
  [error]: form.$(field).error
});