react-native-gifted-form
react-native-gifted-form copied to clipboard
Values are blank if the SubmitWidget is inside a View
Here is my code. Basically I want to have the SubmitWidget and some other component in the same line. But the values passed to onSubmit function is {}
. It works if I move the SubmitWidget outside the view.
<GiftedForm
clearOnClose={false}
openModal={(route) => {
this.props.navigator.push(route)
}}
formName={COMMENT_FORM}>
<GiftedForm.TextAreaWidget
name='comment'
title='Comment'
placeholder='Enter your comments'
autoFocus={true} />
<View style={{flex: 1, flexDirection: 'row'}}>
<View style={{flex: 0.8}}>
<GiftedForm.SubmitWidget
title='Submit'
onSubmit={(isValid, values, validationResults, postSubmit=null, modalNavigator=null) => {
if (isValid) {
this.submitComment(values).
then(() => {
GiftedFormManager.reset(COMMENT_FORM);
});
}
}}
/>
</View>
<View style={{flex: 0.2}}>
SOME OTHER COMPONENT
</View>
</View>
</GiftedForm>
+1
Does it work if you set the formName prop on SubmitWidget to the same used on the Form?
No, it doesn't work.
I have the same problems, even wrapped SubmitWidget
in GroupWidget
.
error messages when click wrapped SubmitWidget
is: undefined is not an object (evaluating 'this.props.form.setState')
This also occurs if you wrapped ErrorsWidget
inside other components.
It would caused by not pass props to children properly?
Im having this same issue.
I found a tricky solution ... add this :
onChangeText={(txt) => {GiftedFormManager.stores.<formName>.values.description = txt}}
in the component !