Copied to clipboard

Flag this post as spam?

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


  • MickaelD 2 posts 71 karma points
    Nov 25, 2019 @ 15:41
    MickaelD
    0

    How to create a multilingual contact form with a custom data model ?

    Hello la team, I want to create a multilingual contact form with a custom data model. I relied on the following example from the Umbraco documentation : sample umbraco v8

    but my website is multi language and I would like to retrieve the property values ​​in the template of my contact page and I encounter difficulties ...

    When i use @inherits Umbraco.Web.Mvc.UmbracoViewPage

    i have an error because already model

    My partial view :

    @model WebSite.Models.ContactFormViewModel
    

    @using (Html.BeginUmbracoForm("Submit", "ContactForm")) { @Html.AntiForgeryToken()

    <div class="widget-contact-form">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    
        <div class="row">
            <div class="form-group col-md-6">
                @Html.LabelFor(model => model.Nom, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.Nom, new { htmlAttributes = new { @class = "form-control", placeholder = "jjj" } })
                    @Html.ValidationMessageFor(model => model.Nom, "", new { @class = "text-danger" })
                </div>
            </div>
            <div class="form-group col-md-6">
                @Html.LabelFor(model => model.Prenom, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Prenom, new { htmlAttributes = new { @class = "form-control", placeholder = "Your Example Here" } })
                    @Html.ValidationMessageFor(model => model.Prenom, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>
    

    My Model :

    using System;
    

    using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web;

    namespace WebSite.Models { public class ContactFormViewModel { [Required] [DataType(DataType.Text)] public string Nom { get; set; } [Required] [DataType(DataType.Text)] public string Prenom { get; set; } [Required] [DataType(DataType.PhoneNumber)] public string Telephone { get; set; } [Required] [DataType(DataType.EmailAddress)] public string Email { get; set; } [Required] [DataType(DataType.Text)] public string ObjetDemande { get; set; } [Required] [DataType(DataType.Text)] public string Message { get; set; } public bool ContactParMail { get; set; } public bool ContactParTelephone { get; set; } public bool RecevoirInformations { get; set; }

    }
    

    }

    Do you have a sample with multi-cultures contact form?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies