Is there a way to find out which form fields are required?

I see that in the ReadOnlyObservableCollection<Syncfusion.Maui.PdfViewer.FormField>, there is a private property named "IsRequired". Is there a way to gain access to this property so that validation can be done accordingly?


Currently if I want to check if the form's fields are required, I need to check if the Text property has any value, but this requires prior knowledge as to which fields are actually required.


3 Replies

MM Manikandan Manickavasagam Syncfusion Team September 27, 2024 03:53 AM UTC

Hi Will,

We are currently checking the feasibility of accessing the IsRequired property of the form fields in the PDF Viewer. We will provide you the further update by September 30, 2024.


Regards,

Manikandan M



BS Bharathi Selvam Syncfusion Team September 30, 2024 04:30 PM UTC

Hi Will,

We are still checking the feasibility of accessing the IsRequired property of the form fields in the PDF Viewer. We will provide you the further update by October 3, 2024.

Regards,

Bharathi S




BS Bharathi Selvam Syncfusion Team October 4, 2024 01:38 AM UTC

Hi Will,

We assume that your requirement is to check whether all required text fields are updated and notify the user to update if any required field is left empty. 

 

To achieve this requirement, you can save the PDF and check whether any required text fields are empty using the PdfLoadedDocument. Please find the code snippet below. Please use this code with the desired form document and let us know whether your requirement is satisfied and let us know if you need any further assistance. 

 

private void validateButton_Clicked(object sender, EventArgs e) {
    Stream saveStream = new MemoryStream();
    pdfViewer.SaveDocument(saveStream); 

    PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(saveStream);
    foreach(PdfLoadedField loadedField in pdfLoadedDocument.Form.Fields)
    {
        if(loadedField is PdfLoadedTextBoxField textBoxField)
        {
            if (textBoxField.Required && string.IsNullOrEmpty(textBoxField.Text))
            {
                DisplayAlert("Alert", "Please fill all the required fields", "OK");
                return;
            }
        }
    }
}

Regards,

Bharathi S


Loader.
Up arrow icon