I am using AJAX function to update a row. When users click on update button, I call an AJAX function which open a div which contains all the form fields. I have rendered a template and passed that as ajax response. However my form contain a textarea inside which html tags does get escaped e.g link would display like
<a href="http://example.com" rel="nofollow" target="_blank">http://example.com/</a>
I have used JSON.stringify
, jQuery.parseJSON
before populating div and twig's raw function on form filed but no success.
My form field looks like :
{{ form_widget(form.comments,{ 'value': obj.comments|raw}, {'attr':{'style':'width:'}}) }}
I believe, it has nothing to do with JSON as the template is triggered before encoding the content but I wanted to describe the whole scenario.
Controller
$content = $this->renderView("ex.html.twig", array('form'=>$form->createView()));
return new Response(json_encode($content), 200, array("Content-Type" => "application/json"));