Laravel 4.2 br tags to nl in textarea makes double tags

旧时模样 提交于 2019-12-24 08:04:06

问题


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.

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')) }}

thanks for the help in advance :)


回答1:


Try this,

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

Hope it help.



来源:https://stackoverflow.com/questions/41237956/laravel-4-2-br-tags-to-nl-in-textarea-makes-double-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!