Whilst there is a lot of documentation on validating forms when they are in Edit Mode, there does not seem to be alot of documentation about validating a form when in New Mode.
I would like to make sure all of the fields marked as "Required" have actually got something in them and the entered value is acually the right type (integer, string etc). Each card on the form has got "Required" set to true.
I would like to validate the form before I submit it. (Form.Valid does not seem to work for forms in Form.Mode = FormMode.New)
Have i missed something ?
Hi @NigelP ,
Could you please share a bit more about your scenario?
Do you want to validate a New Form using the Form.Valid formula?
Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. The Form.Valid formula works well with All Required fields within my New Form. On my side, I set the OnSelect property of the "Submit" button to following:
Notify("There are some invalid values in your Edit form", NotificationType.Error)
Please make sure you have set the Required property to true for all fields in your Edit form, and provide values for these Required fields when you test the Form.Valid formula.
Please consider take a try to re-create a new app based on your data source, set the OnSelect property of the "Submit" button to following:
If( YourEditForm.Valid, SubmitForm(YourEditForm), Notify("There are some invalid values in your Edit form", NotificationType.Error) )
In addition, as an alternative solution, please also take a try with the following workaround:
Set the OnSelect property of the "Submit" button to following:
If( !IsBlank(DataCardValue1.Text) && !IsBlank(DataCardValue2.Text) && !IsBlank(DataCardValue3.Selected.Value) && ... , SubmitForm(YourEditForm), Notify("There are some invalid values in your Edit form", NotificationType.Error) )
Note: The DataCardValue1, DataCardValue2, DataCardValue3, ... represents the Input controls in your Edit form.
I will try and explain more what I am going to achieve....
If I have a form which is in Edit Mode, then the Valid Property of the Form continuously updates (true / False / True etc) as I update fields.
If I take the same form and put it into New Mode (New_Form(MyForm)) the Valid proprty does not continuously update as I enter the fields.
I can reproduce this behaviour by inserting a Label above the form and setting its Text property to MyForm.Valid and observing it when the form is in Edit mode and I am changing fields and then again when it is in New Mode.
Check out new user group experience and if you are a leader please create your group
Check out how to claim yours today!
Test your skills now with the Cloud Skill Challenge.