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?
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>
}
}
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.
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?
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.
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!
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!
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>
}
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.
Do anyone know how to fix this or maybe just have an idea of how to fix it?
Regards,
Allan
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
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
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.
HTH
Steve
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
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?
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
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
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
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!
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
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
is working on a reply...