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
Hi,
I have a form setup and have an email being sent using the default Umbraco email template.
However, when the email comes through, the @field.Name isn't showing above the field values.
@field.Name
I've updated to the latest version supporting 9 (9.5.1) and also tried 9.5.0 with no luck.
9.5.1
9.5.0
If I use @field.Alias this works as expected.
@field.Alias
A screenshot of the email:
The template I'm using is:
@foreach (var field in Model.Fields.Where(x => ignoreFields.Contains(x.FieldType) == false)) { <h4 style="font-weight: 700; margin: 0; color: #000000;">@field.Name</h4> <p style="margin-top: 0;"> @switch (field.FieldType) { case "FieldType.FileUpload.cshtml": var uploadCount = 0; foreach (var fileUploadValue in field.GetValues()) { if (fileUploadValue != null && !string.IsNullOrEmpty(fileUploadValue.ToString())) { uploadCount++; } } if (uploadCount > 0) { <span>@uploadCount file@(uploadCount == 1 ? string.Empty : "s") uploaded</span> } break; case "FieldType.DatePicker.cshtml": var datePickerValue = field.GetValue(); if (datePickerValue != null && !string.IsNullOrEmpty(datePickerValue.ToString())) { DateTime dt; var dateValid = DateTime.TryParse(datePickerValue != null ? datePickerValue.ToString() : string.Empty, out dt); var dateStr = dateValid ? dt.ToString("f") : ""; @dateStr } break; default: var values = field.GetValues(); if (values != null) { foreach (var value in values) { if (value != null) { @(value is string ? value.ToString().ApplyPrevalueCaptions(field.Id, Model.PrevalueMaps) : value)<br /> } } } break; } </p> }
Thanks,
Ben
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco Forms - Field Names Not Showing in Email Template (Razor)
Hi,
I have a form setup and have an email being sent using the default Umbraco email template.
However, when the email comes through, the
@field.Name
isn't showing above the field values.I've updated to the latest version supporting 9 (
9.5.1
) and also tried9.5.0
with no luck.If I use
@field.Alias
this works as expected.A screenshot of the email:
The template I'm using is:
Thanks,
Ben
is working on a reply...