Hi. I have a portal page template in a checkout process that hosts a BizForm control to collect some additional information for a user during checkout. When valid data is submitted on the form I store the submitted data in the cart item custom data for future processing.
However, if the user wants to add another item to their basket and re-enters checkout I want to retrieve the data already submitted previously and pre-populate the form fields with that data so the user doesn't have to fill it in again. I am struggling to get the data to show in the form fields so a bit stuck on what to do next. Here is my code:
form.SubmitButton.Visible = false; form.ReloadData(); var cartItem = CurrentCart.CartItems .FirstOrDefault(ci => ci.CartItemID.ToString().Equals(cartItemId)); var existingFormDataId = ValidationHelper.GetInteger(cartItem?.CartItemCustomData.GetValue("FormItemID"), 0); BizFormItem currentData = null; if (existingFormDataId > 0) { currentData = BizFormItemProvider.GetItem(existingFormDataId, $"BizForm.{form.FormName}"); } if (currentData != null) { foreach (var field in form.Fields) { var fieldValue = currentData?.GetValue(field); form.Data.SetValue(field, fieldValue); } // What next? }
Can anyone suggest what I am missing here and how I can get the existing data to pre-populate in the form fields? Many thanks.
Al, did you ever find a solution to this? I'm trying to do something similar and am coming up empty. From everything I've found so far, the solution is to set the fields with the "form.Data.SetValue()" method, but that doesn't do it.
Please, sign in to be able to submit a new answer.