Created
January 5, 2017 13:18
-
-
Save kitze/a4f04b2b6e52fa5dc4e7167fac13d3dc to your computer and use it in GitHub Desktop.
bindField function for mobx-react-form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment