FaridSafi / react-native-gifted-form

📝 « One React-Native form component to rule them all »
MIT License
1.44k stars 214 forks source link

Values are blank if the SubmitWidget is inside a View #67

Open chiraggshah opened 8 years ago

chiraggshah commented 8 years ago

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>
samdturner commented 8 years ago

+1

deckchairlabs commented 8 years ago

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

zxcpoiu commented 8 years ago

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?

j-mendez commented 8 years ago

Im having this same issue.

MisterAlex95 commented 7 years ago

I found a tricky solution ... add this :

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

in the component !