FaridSafi / react-native-gifted-form

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

Way to submit a form programatically #80

Open TroutZen opened 8 years ago

TroutZen commented 8 years ago

Is there a way to submit the form programmatically? Use case: currently using react-native-router-flux and want to bind a form submit to their Scene onRight callback.

sambwest commented 8 years ago

I am also using react-native-router-flux with success.

If you don't care about displaying errors you can do the following...

var validationResults = GiftedFormManager.validate('formname');
if(validationResults.isValid) {
    var values = GiftedFormManager.getValues('formname');

    // do your processing here

    // remove the scene
    Actions.pop();
}

I have submitted a pull request that allows you to programmatically display the errors too, the problem is it's 22 days old and and the developer doesn't seem to be active anymore.

Hope this helps.