Copied to clipboard

Flag this post as spam?

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


  • Joel 23 posts 108 karma points
    Sep 21, 2017 @ 21:17
    Joel
    0

    Umbraco Forms multilingual placeholders

    Hi all,

    I'm having an issue in Umbraco 7.6.4 with Umbraco Forms 6.0.2.

    I have a stack of dictionary items that I'm using to create a multilingual form.

    I'm using the approach of adding the hashtag in front of labels/field names to get the correct language on the front end, eg #Company, #Email, etc.

    It's all working perfectly for the field name, help text and default value, except that the placeholder value isn't showing as translated, it just shows literally #Company as the placeholder value - it's not even showing the default English value which tells me it isn't being parsed like the other attributes.

    Is there a quick fix? Anyone else experiencing the same bug?

  • Joel 23 posts 108 karma points
    Sep 24, 2017 @ 23:52
    Joel
    102

    I've figured out this issue and implemented a workaround.

    I added the code as shown at http://issues.umbraco.org/issue/CON-1161, however rather than putting it in “Views\Partials\Forms\Form.cshtml” as suggested, I needed to enter in into the file “Views\Partials\Forms\Themes\default\Form.cshml”

    It’s also worth pointing out the code had to be toward the top of the codeblock and not at the bottom. Ie.

        @foreach (FieldViewModel f in c.Fields)
        {
        bool hidden = f.HasCondition && f.ConditionActionType == FieldConditionActionType.Show;
    
        if (!string.IsNullOrEmpty(f.PlaceholderText) && f.PlaceholderText.StartsWith("#"))
        {
        f.PlaceholderText = umbraco.library.GetDictionaryItem(f.PlaceholderText.TrimStart("#"));
        }
    
        <div class="@Html.GetFormFieldWrapperClass(f.FieldTypeName) @f.CssClass" @{ if (hidden) { <text> style="display: none" </text>   } }>
        @if (!f.HideLabel)
    ...
    
  • Doobear 21 posts 111 karma points
    Oct 30, 2017 @ 15:38
    Doobear
    0

    Hi Joel.

    I have just posted on the forum about getting Forms working with multi language sites and then I saw your post. I wondered if you'd be able to give me an insight into how you have set this up.

    I am using v7.6.5 and have tried the # approach by adding the # infront of the field name and then adding the dictionary entries by the same name, this approach works perfectly with the custom drop down lists I have created but not with the form fields. See my screenshots below but if you can offer any advice of this I'd be ever grateful.

    enter image description here

    enter image description here

  • Joel 23 posts 108 karma points
    Oct 30, 2017 @ 22:37
    Joel
    0

    Hi Doobear,

    What you've got setup in those screenshots is correct. Other than what you've got setup, it should work out of the box.

    Have you got screenshots of the front end in English and Romanian to see the output?

  • Doobear 21 posts 111 karma points
    Oct 31, 2017 @ 08:01
    Doobear
    0

    Hi Joel,

    Thanks for getting back to me and confirming that what I have done does seem to be right, sometimes I think I am going mad!

    I have set the Home node culture setting to be ro-RO and all of my other dictionary entries are working just fine. You can see the culture setting attached and the form on the front end. It just isn't working. I wondered if there was a setting in a config file somewhere or something else I had to edit to get the dictionary working with forms.

    Again, many thanks.

    enter image description here enter image description here

  • Joel 23 posts 108 karma points
    Oct 31, 2017 @ 10:38
    Joel
    1

    No worries at all. All it appears that you've done wrong is entered the key of the dictionary item incorrectly. The key name shouldn't be #Name, rather just Name.

  • Doobear 21 posts 111 karma points
    Oct 31, 2017 @ 10:53
    Doobear
    0

    Ahhh, Thank you so much, you have saved me a massive headache! It is working perfectly now. Yay!

    Thanks again Joel.

Please Sign in or register to post replies

Write your reply to:

Draft