Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am currently trying to develop a front-end for viewing entries to one of the forms in our umbraco forms system. Unfortunately, I can't seem to work out how to get the fields ordered the same way as they are in the front end. I've got the following code:
var record = Library.GetApprovedRecordsFromForm(formId).Items.First(x => x.Id == recordId);
@foreach (var recordField in record.RecordFields)
<div class="input-group contour">
<input type="text" disabled="disabled" class="input-group-field input-group-display" value="@recordField.Value.ValuesAsString(false)" />
This does produce output but it seems to sort in a completely random order. I've seen examples using .OrderBy(r => r.Value.Field.PageIndex) but this property no longer seems to exist!
Can anyone offer any suggestions as to how to get this working?
It looks like it's a bug:
Ahh, open since February too, guess it's not going to be fixed any time soon! Oh well...
By the way, maybe Umbraco Forms 6 hasn't this bug?
What version are you using?
Good catch, i'm not on 6! I just installed it yesterday through the forms page in the backend so assumed I had the latest version but we're on umbraco 7.5.x so only got the v4 of forms! Looks like i've got some upgrading to do!
Thanks for your help
You are welcome, Chris. Have a great weekend.
Nope, still an issue in 6. It still brings them back in a random order. It wouldn't be a problem if they were in the same order as in the backend!
I was experiencing this issue running Umbraco Forms 6.0.8. I managed to work around it however after finding out that calling the GetForm() message on an instance of Form will return the fields in the correct order.
Annoyingly, the field instances under Form.AllFIelds don't hold values for their Values property so you still have to use RecordStorage to get the values.
This is what I ended up writing:
public static IEnumerable<RecordField> GetRecordValues(Guid recordUniqueId)
using (var formStorage = new FormStorage())
using (var recordStorage = new RecordStorage())
var record = recordStorage.GetRecordByUniqueId(recordUniqueId);
var form = record.GetForm();
var orderList = form.AllFields.Select(x => x.Alias).ToList();
return record.RecordFields.Select(x => x.Value)
Hope this helps!
Nice one Aaron, you have helped me! Thanks. #h5yr
Been having this issue myself and just found this thread. Will try Aaron's solution, but is this a bug that hasn't been fixed since 2017?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted