Laravel 4.2 BR标签到textarea中的nl使双重标签 [英] Laravel 4.2 br tags to nl in textarea makes double tags

查看:90
本文介绍了Laravel 4.2 BR标签到textarea中的nl使双重标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在Laravel 4.2中遇到了这个问题,即我有一个textarea用于更新关于我"的用户配置文件,如果我从数据库中删除它,它工作正常,我尝试执行nl2br并隐藏br标签,问题是,当我从头开始编写并使文本如下时,问题就出现了:

so i have this problem with Laravel 4.2, that i have a textarea for updating the user profiles "about me", if i take it down from the database it works fine, i tried to do nl2br and hide the br tags, sort of worked aswell, problem is, when i write from scratch and make text like:

"hello

welcome to my profile"

在提取到的页面上看起来不错,但是,如果我再次进入个人资料编辑页面,它将以两倍的空格显示:

it looks fine on the page it's extracted to, however, if i enter my profile editing page again, it will display with twice the space as such:

"hello



welcome to my profile"

我不确定如何解决此问题,但希望其他人可能知道.

i'm not exactly sure how to fix this, but hoping someone else may know.

我目前用于提取它的laravel代码是这样的:

my laravel code for extracting it at the moment is this:

{{ Form::textarea('about_me', $user->about_me = str_replace("<br />", "\n", $user->about_me), array('class' => 'profile-input')) }}

感谢您的提前帮助:)

推荐答案

尝试一下,

{{ Form::textarea('about_me', nl2br(e($user->about_me)), array('class' => 'profile-input')) }}

希望有帮助.

这篇关于Laravel 4.2 BR标签到textarea中的nl使双重标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆