I managed to create a page that will dynamically display data from the database. However, this code is stored in the database:
<p>This is the content for the radio <a href="#">page</a>.</p>
It is displayed as follows:
<p>This is the content for the radio <a href="#">page</a>.</p>
HTML tags are not displayed. I understand that Symfony (for security purposes) provides HTML code like this for security reasons. I want Symfony (obviously) to display these HTML tags. How can I achieve this for this purpose only, so that Symfony will still sanitize any HTML tag that is stored in the database elsewhere on the site?
For your information, this is the code that I use to pull data from a database:
public function mainpageAction($slug) { $content = $this->getDoctrine() ->getRepository('SiteMainBundle:Content') ->find($slug); if (!$content) { throw $this->createNotFoundException('No product found for slug '.$slug); } return $this->render('SiteMainBundle:Default:page.html.twig', array('content' => $content, 'slug' => $slug)); }
Also, so that I can learn more about Symfony, is rendering HTML tags the only PHP job or can it be displayed correctly using Twig?
Many thanks!
source share