react-native-gifted-form icon indicating copy to clipboard operation
react-native-gifted-form copied to clipboard

Values are blank if the SubmitWidget is inside a View

Open chiraggshah opened this issue 8 years ago • 5 comments

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>

chiraggshah avatar Jun 09 '16 13:06 chiraggshah

+1

samdturner avatar Jun 15 '16 21:06 samdturner

Does it work if you set the formName prop on SubmitWidget to the same used on the Form?

deckchairlabs avatar Jun 20 '16 05:06 deckchairlabs

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?

zxcpoiu avatar Jun 22 '16 10:06 zxcpoiu

Im having this same issue.

j-mendez avatar Aug 06 '16 01:08 j-mendez

I found a tricky solution ... add this :

onChangeText={(txt) => {GiftedFormManager.stores.<formName>.values.description = txt}}

in the component !

MisterAlex95 avatar Aug 30 '17 15:08 MisterAlex95