submit method
dynamic
submit({})
Submit the form
If the form is valid, it will call the onSuccess
function
Implementation
submit(
{required Function(dynamic value) onSuccess,
Function(Exception exception)? onFailure,
bool showToastError = true}) {
Map<String, dynamic> rules = getValidate;
if (rules.isEmpty) {
Map<String, dynamic> currentData = data();
// convert all keys to lowercase with underscores
Map<String, dynamic> newData = {};
for (var entry in currentData.entries) {
newData[entry.key.toLowerCase().replaceAll(" ", "_")] = entry.value;
}
onSuccess(newData);
return;
}
NyForm.submit(stateName,
onSuccess: onSuccess,
onFailure: onFailure,
showToastError: showToastError);
}