DataObject - Last property in model always empty
We have created two views from the templates, these views use the SfDataForm control. The views are displayed correctly however, on a click event and we inspect the DataObject the last property of the model is always an empty string.
For example
public class SignUpInfo
{
public SignUpInfo()
{
Name = string.Empty;
Email = string.Empty;
Password = string.Empty;
ConfirmPassword = string.Empty;
}
[Display(Name = "Name")]
[DataFormDisplayOptions(ColumnSpan = 3)]
[Required(ErrorMessage = "Enter your name")]
public string Name { get; set; }
[Display(Name = "Email")]
[DataFormDisplayOptions(ColumnSpan = 3)]
[EmailAddress(ErrorMessage = "Enter your email")]
public string Email { get; set; }
[Display(Name = "Password")]
[DataType(DataType.Password)]
[Required(ErrorMessage = "Enter a password")]
[DataFormDisplayOptions(ColumnSpan = 3)]
public string Password { get; set; }
[Display(Name = "Confirm Password")]
[DataType(DataType.Password)]
[Required(ErrorMessage = "Please confirm password")]
[Compare(nameof(Password), ErrorMessage = "Confirmed password does not match")]
[DataFormDisplayOptions(ColumnSpan = 3)]
public string ConfirmPassword { get; set; }
}
((SignUpInfo)dataForm.DataObject).ConfirmPassword is empty
public class LoginFormInfo
{
public LoginFormInfo()
{
Email = string.Empty;
Password = string.Empty;
}
[Display(Name = "Email")]
[DataFormDisplayOptions(ColumnSpan = 3)]
[EmailAddress(ErrorMessage = "Enter your email")]
public string Email { get; set; }
[Display(Name = "Password")]
[DataType(DataType.Password)]
[Required(ErrorMessage = "Enter the password")]
[DataFormDisplayOptions(ColumnSpan = 3)]
public string Password { get; set; }
}
((LoginFormInfo)dataForm.DataObject).Password is empty
public class ForgotPasswordInfo
{
public ForgotPasswordInfo()
{
Email = string.Empty;
}
[Display(Name = "Enter mail address")]
[DataFormDisplayOptions(ColumnSpan = 3)]
[EmailAddress(ErrorMessage = "Enter your email")]
public string Email { get; set; }
}
}
((ForgotPasswordInfo)dataForm.DataObject).Email is empty
We are using Syncfusion.Maui.DataForm v 28.2.5
Any help is much appreciated
Hi DevOps,
Thank you for contacting us. To resolve the problem with the last property in your model being empty, we suggest setting the `CommitMode` to `PropertyChanged`. This will ensure that the data is committed to the underlying property as soon as the user makes changes. Here's an example:
|
<dataForm:SfDataForm x:Name="dataForm" AutoGenerateItems="True" CommitMode="PropertyChanged" LayoutType="TextInputLayout" DataObject="{Binding LoginFormInfo}" />
|
We have also created a simple sample to illustrate this solution. Please find the attached sample for your reference.
If you have any further questions or need additional assistance, please don’t hesitate to let us know. We are here to help!
Regards,
Vidyalakshmi M.
Attachment: MAUIDataForm_6dd40c40.zip
Thank you, I can confirm that has resolved the i
Hi DevOps,
We are glad that your issue has been resolved! Please let us know if you need further assistance. As always, we are happy to help you out.
Regards,
Vidyalakshmi M.
- 3 Replies
- 2 Participants
- Marked answer
-
DO DevOps Olive
- Feb 15, 2025 03:38 PM UTC
- Feb 18, 2025 05:41 AM UTC