FaridSafi/react-native-gifted-form

Way to submit a form programatically

TroutZen opened this issue · 1 comments

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.

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.