neoneye / SwiftyFORM

iOS framework for creating forms
MIT License
1.07k stars 87 forks source link

Explanation of validateAndUpdateUI() vs validate() #65

Open justdan0227 opened 3 years ago

justdan0227 commented 3 years ago

Can you provide an explanation of the two in the documentation? Thanks!

neoneye commented 3 years ago

Invoking form_installSubmitButton() and a "Submit" button gets shown in the navigation bar. It shows an alert with validation status. The form_installSubmitButton() can used during development for validating the form.

When the form actually have to be submitted to a server or similar, then one will have to make a custom function for uploading to the server.

justdan0227 commented 3 years ago

Oh I'm so sorry.. I didn't explain my question. I have a submit button that when pressed I call

formBuilder.validateAndUpdateUI()

let result = formBuilder.validate()

I check the result from formBuilder.validate(), but I"m not sure what formBuilder.validateAndUpdateUI() does (but saw it in your example code). I don't see those calls documented.

neoneye commented 3 years ago

It seems to end up calling TextFieldCell.reloadPersistentValidationState. This function invalidates a timer and hides an eventual error message shown below the textfield.

Sorrry, I can't remember what I intended with validateAndUpdateUI.