I have a problem with saving the radio button when the radio button is not selected but as loaded data

荒凉一梦 提交于 2020-01-06 05:46:22

问题


Radio button saves to the database if i select it. But if it loads the radio button on which gender i chose(Male) and i don't touch the radio buttons only other fields to save, it saves the gender as empty?

                {this.state.gender == "Male" ? (
                  <RadioForm
                    radio_props={radio_props}
                    initial={0}
                    onPress={value => {
                      this.setState({ value });
                    }}
                  />
                ) : this.state.gender == "Female" ? (
                  <RadioForm
                    radio_props={radio_props}
                    initial={1}
                    onPress={value => {
                      this.setState({ value });
                    }}
                  />
                ) : (
                    <RadioForm
                  radio_props={radio_props}
                  initial={-1}
                  onPress={value => {
                    this.setState({ value });
                  }}
                />
                )}


How can the value Male or Female just save to the database also when i am loading data without touching the Radio button options. Is it because of the OnPress?

Thanks for your time!

来源:https://stackoverflow.com/questions/58452358/i-have-a-problem-with-saving-the-radio-button-when-the-radio-button-is-not-selec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!