Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS 3.0.3 - Text field content display problems


Go to End


5 Posts   521 Views

Avatar
nzstephenf

Community Member, 63 Posts

7 November 2014 at 3:47pm

Hey people of the community,
Need a bit of help with trying to fixing this problem that causes data that is of a "TEXT" database-field type to not show the correct paragraph formatting in template but appears fine with the right enter/return gaps in the text area when editing it.

$Description.RAW - Does not work at all.

Is there any solution in fixing this issue without doing major things like upgrading.
Cheers!

I've attached some examples of the issue that I've been having.

Attached Files
Avatar
martimiz

Forum Moderator, 1391 Posts

8 November 2014 at 2:40am

Are you sure this is not just a css issue? Have you checked if 'under the hood' the HTML is the same?

Avatar
nzstephenf

Community Member, 63 Posts

9 November 2014 at 11:21pm

Nope, it's not a CSS issue. We use the 3.0.3 version for our main site but on our new site, we're running 3.1.6 and it appears that the bug has sorted itself out on that.

Any help or tips on fixing this up? The thing is that we use NO HTML tags and the paragraphing is based purely on what is entered in the textarea on the frontend form.

Avatar
kinglozzer

Community Member, 187 Posts

14 November 2014 at 6:11am

Hi Stephen,

This was fixed here: https://github.com/silverstripe/silverstripe-framework/pull/2034. If you need to replicate the behaviour before this patch was applied, you’ll need to add an extension to StringField with a method NL2BR_SS or something and then use $MyField.NL2BR_SS in your template:

class StringFieldExtension extends Extension {
    public function NL2BR_SS() {
        return nl2br($this->owner->value);
    }
}

Loz

Avatar
nzstephenf

Community Member, 63 Posts

14 November 2014 at 6:14pm

Thanks heaps Loz!
You're a life saver! :) Have yourself a great Friday - because you've just solved a problem I've had for ages.