Copied to clipboard

Flag this post as spam?

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


  • Allan Lange 6 posts 96 karma points
    Apr 13, 2016 @ 08:25
    Allan Lange
    0

    Repeatable textstrings outputs empty strings

    Hi everyone,

    I'm having an issue with the Repeatable Textstrings editor outputting empty strings and I do not know why or how to fix the issue.

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    Do anyone know how to fix this or maybe just have an idea of how to fix it?

    Regards,

    Allan

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Apr 13, 2016 @ 08:40
    Steve Morgan
    0

    Hi Allan,

    Are you using LeBlender or something similar?

    I helped someone once that had found that the string array was being converted to JSON by LeBlender.

    Try the fix proposed in this thread.

    https://our.umbraco.org/projects/backoffice-extensions/leblender/general-discussion/70196-how-to-use-multiple-textbox

    I've just created a "clean" example of a repeatable text field and it works as expected (e.g. your code above should work) but looking at your code you have a number of meetings in a tab so I'm guessing you have some kind of composite doc type setup?

    HTH

    Steve

  • Allan Lange 6 posts 96 karma points
    Apr 13, 2016 @ 08:49
    Allan Lange
    0

    Hi Steve,

    Thank you for replying to my thread.

    I'm not using LeBlender or anything similar for this project.

    The setup is Nested Content within a Nested Content, so yes some kind of composite doc type setup. I do not know how to explain it in further detail.

    Hopefully it gives you an idea of the setup.

    Regards,

    Allan

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Apr 13, 2016 @ 09:41
    Steve Morgan
    100

    Hi Allan,

    So you have the Nested Content package installed?

    I've just installed this and tested something close to what I think you've setup and I can recreate what you're seeing.

    I'm not entirely sure but I suspect the issue is in the package and how it serialises and deserialised the nested data) - it looks like it's storing them with carriage returns as a "\r\n" both of which is then being converted separately. The repeatable text string data type is not that widely used in my experience so I bet it's just not been tested.

    The safest workaround would be to just test for an empty string and skip those. I'd recommend you report this as a bug on the Nested Content package forum though.

    var meetingPackagesTab = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("MeetingPackagesTab");
        }
    
    
        @foreach (var meeting in meetingPackagesTab)
        {
            var hasBullets = meeting.HasValue("bullets");
            var bullets = meeting.GetPropertyValue<string[]>("bullets");
    
            if (hasBullets)
            {
                <ul>
                    @foreach (var bullet in bullets)
                    {
                       // TEST FOR EMPTY STRING
                        if (!bullet.IsEmpty())
                        {
                            <li>@bullet</li>
                        }
                    }
                </ul>
            }
        }
    

    enter image description here

    HTH

    Steve

  • Allan Lange 6 posts 96 karma points
    Apr 13, 2016 @ 09:51
    Allan Lange
    0

    Hi Steve,

    The workaround of checking for empty strings and skipping those works like a charm.

    However it is not the best solution it is the one I'm going with for now. As per your advice, I will report the bug on the Nested Content package forum and link to this thread giving them a better idea of the issue. Hopefully the developer will fix the bug in a future update.

    Again thank you so much.

    Best regards,

    Allan

  • Bendik Engebretsen 105 posts 202 karma points
    Oct 11, 2016 @ 14:29
    Bendik Engebretsen
    0

    Hello Allan and Steve,

    I'm having the same problem now, using Umbraco 7.5.3, and I don't have the Nested Content package installed. My project is a straight Umbraco installation, I have just customized the Fanoe kit a little bit and created some document types and templates. My code is very similar to Allan's. So, I suspect that this could be a bug in Umbraco. Could anyone from the Umbraco team have a quick look at this?

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Oct 11, 2016 @ 14:35
    Steve Morgan
    0

    Really? When I tried to recreate the OPs problem using the vanilla setup I couldn't.

    If you can post some code that would help. If you can make something repeatable I suggest you raise an issue on the Issue Tracker.

    Again the repeatable text strings are not widely used so I wouldn't expect a patch or fix instantly either way. You're best to null check / workaround as above.

    HTH Steve

  • Paul Griffiths 370 posts 1021 karma points
    Oct 14, 2016 @ 07:17
    Paul Griffiths
    0

    Hi all,

    I landed on this thread because i have the same issue.

    I have a standard umbraco installation and i have the same issue when using the repeatable strings data type. It keeps outputting blank strings.

    I have used the workaround which works great ;) but is suspect that there is definately a bug elsewhere.

    Thought id report this.

    Thanks

    Paul

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Oct 14, 2016 @ 07:40
    Steve Morgan
    0

    If you can produce this behaviour I suggest you raise a ticket here with the steps:

    http://issues.umbraco.org/dashboard

    You never know - some UK Umbracicorns might fix it at the hackathon :) (I'd like to have a go!)

    Steve

  • Bendik Engebretsen 105 posts 202 karma points
    Oct 17, 2016 @ 11:22
    Bendik Engebretsen
    2

    Aha: While trying to reproduce the problem, I found out that it occurs only when Minimum (Enter the minimum amount of text boxes to be displayed) in the settings of the Repeatable Textstrings editor is set to 0 (zero). So, just set it to 1 (or higher) and everything works fine!

  • Paul Griffiths 370 posts 1021 karma points
    Oct 17, 2016 @ 12:46
    Paul Griffiths
    0

    Nice Find and thanks for sharing!

    For the record, each time I have used this data type I have set the minimum amount to 0 and each time I have had this issue. Your definitely on to something I think!

    Paul

  • Richard Hamilton 79 posts 169 karma points
    Jul 14, 2017 @ 12:00
    Richard Hamilton
    0

    I tried setting minimum to 1 or 2 and still get the empty strings. I will check for empty strings (probably a good idea anyway). Simplified the check by Steve Morgan

    @foreach (var bullet in bullets.Where(x => !string.IsNullOrWhiteSpace(x))
                {
                        <li>@bullet</li>
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft