Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Karen 8 posts 98 karma points
    Oct 04, 2019 @ 13:23
    Karen
    0

    Updating email template (Partial Views/forms/Emails) to show caption from fieldset

    Hi, I am using Umbraco 7 and have copied the Example-Template and adjusted it. We would like to display the fields under the headings of their fieldset captions.

    I would appreciate any help. The inner foreach works but the outer foreach is not producing an h3 caption.

    We would also like to have a line break after each return the person completing the form makes when filling in a textArea field.

    Thank you for any advice (Not sure if 'Model.Fieldsets' is correct )

    <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #303033; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                        @foreach (var fieldset in Model.Fieldsets){
                            if (!string.IsNullOrWhiteSpace(fieldset.Caption)) {
                                <h3 style="font-weight: 700; margin: 0; color: #000000;">@fieldset.Caption</h3>
                            }
                            @foreach (var field in Model.Fields)
                                {
                                    var fieldVal = field.GetValue();
                                    if(!fieldVal.ToString().Contains("False") && fieldVal!=""){  
                                        <h4 style="font-weight: 700; margin: 0; color: #000000;">@field.Name</h4>
    
                                        switch (field.FieldType)
                                        {
                                            case "FieldType.FileUpload.cshtml":
                                                <p style="margin-top: 0;"><a href="@siteDomain/@field.GetValue()" target="_blank" style="color: #00AEA2;">@field.GetValue()</a></p>
                                                break;
    
                                            case "FieldType.DatePicker.cshtml":
                                                <p style="margin-top: 0;">@(Convert.ToDateTime(field.GetValue()).ToString("f"))</p>
                                                break;
    
                                            case "FieldType.CheckboxList.cshtml":
                                                <p style="margin-top: 0;">
                                                    @foreach (var color in field.GetValues())
                                                    {
                                                        @color<br/>
                                                    }
                                                </p>
                                                break;
                                            default:
                                                <p style="margin-top: 0;">@field.GetValue()</p>
                                                break;
                                        }
                                    }
                                }
                                <hr/>
                            }
                        </td>
    
  • Karen 8 posts 98 karma points
    Oct 07, 2019 @ 13:22
    Karen
    0

    It's ok, found the issue - it won't call the fieldset because the FormsHTMLModel doesn't collect or enable this info to be passed to the email template.

    @inherits UmbracoViewPage<Umbraco.Forms.Core.Models.FormsHtmlModel>
    

    The code that needed adding for a linebreak was

     default:
     <p style="margin-top: 0;">@Html.Raw(field.GetValue().ToString().Replace("\n","<br />"))</p>
                                            break;
    

    Hope someone else finds this useful Thank you

Please Sign in or register to post replies

Write your reply to:

Draft