1

I have CKEditor enabled for details in my view for Projects. All is working fine as in I can create a new project and it saves to the database. When I look in the projects table in the details column I see my html <p>This is some details</p>. When I try showing the $project->details in a view it does not render the HTML and just prints to <p>This is some details</p> the screen.

As this answer suggests From my blade file I tried {{ html_entity_decode($project->details) }} and it does the same thing (doesnt render html from database). I believe this is specific to Laravel and how it fetches/stores the data because I previously had this project in Codeigniter and was able to simply echo the value to the screen.

When I use {{ html_entity_decode($project->details) }}I Get this: with html entity decode

This will render the HTML but I don't think it is how I should be doing it and it prints a number (in this case 1) after the HTML. {{ print($project->details) }}

This is what happens when I use (notice the random 1 at the bottom) {{ $project->details }} using print

Here is my DB table database table

How do I get the html to render on the page/is print the best way to do this in laravel or php?

2
  • It'd be easier for others to understand exact problem by printing the exact result. Commented Dec 27, 2016 at 17:03
  • When I use {{ html_entity_decode($project->details) }} in my view it prints <p>This is some details</p>. When I use {{ print($project->details) }} it prints This is some details 1. In my projects table in the details column I see <p>This is some details</p>. I will try to add some screenshots to see if it makes the question clearer. Commented Dec 27, 2016 at 17:08

1 Answer 1

1

There's no reason why that '1' should show up. Can you make sure you don't have any Mutators on your model.

Also if you are pretty sure about all the data coming from your DB and want to output the html as is you can try {!! $project->details !!}

Sign up to request clarification or add additional context in comments.

2 Comments

{!! $project->details !!} did the trick. Can you tell me what the difference is in using {{ $project->details }} and {!! $project->details !!}?
Outputting variables using: {{ $variableName }} executes an escape string method before actually displaying the variable's value to avoid XSS Attacks and injecting any sort of script into your page especially if the value of that variable was set from a public facing input. Using {!! !!} is like telling blade not to escape any sorts of scripts (including html tags) and should be only used if you're sure 100% that the value of your variable doesn't have any maleficent script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.