Derek
Derek

Reputation: 5037

Laravel CKEditor Saves to DB but HTML does not render on page

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?

Upvotes: 1

Views: 2204

Answers (1)

yahyazini
yahyazini

Reputation: 716

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 !!}

Upvotes: 1

Related Questions