FaridSafi / react-native-gifted-form

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

edit field editable programmically #128

Open Dannnyho opened 6 years ago

Dannnyho commented 6 years ago

Is there any way to edit field editable programmically? I want to add a "edit" button to enable the all field editable = true

sambwest commented 6 years ago

Hi,

You can do it by editing the containers state.

constructor(params) {
        super(params);
        this.state = {
            emailEditable: false
        }
    }

Then on the field:

<GiftedForm.TextInputWidget
  name='email'
  title='Email:'
  editable={this.state.emailEditable}
/>

Then in your button:

_toggleEditable() {
  this.setState({emailEditable: !this.state.emailEditable});
}