export raw string (no html conversion) and replace " by "" - refs #401

This commit is contained in:
Marc Ducobu 2015-02-18 12:41:57 +01:00
parent 47a9a29236
commit b40a1595c1
3 changed files with 13 additions and 6 deletions

View File

@ -3,12 +3,13 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop> * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -92,8 +93,13 @@ class CustomFieldText implements CustomFieldInterface
public function render($value, CustomField $customField, $documentType = 'html') public function render($value, CustomField $customField, $documentType = 'html')
{ {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:text.html.twig';
if($documentType == 'csv') {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:text.csv.twig';
}
return $this->templating return $this->templating
->render('ChillCustomFieldsBundle:CustomFieldsRendering:text.html.twig', array('text' => $value)); ->render($template, array('text' => $value));
} }
public function serialize($value, CustomField $customField) public function serialize($value, CustomField $customField)

View File

@ -2,9 +2,9 @@
{%- for choice in choices -%} {%- for choice in choices -%}
{% if choice['slug'] in selected %} {% if choice['slug'] in selected %}
{%- if choice['slug'] is not same as('_other') -%} {%- if choice['slug'] is not same as('_other') -%}
{{ choice['name']|localize_translatable_string }} {{ choice['name']|localize_translatable_string|replace({'"':'""'})|raw }}
{%- else -%} {%- else -%}
{{ choice['name'] }} {{ choice['name']|replace({'"':'""'})|raw }}
{%- endif -%} {%- endif -%}
{% endif %} {% endif %}
{%- endfor -%} {%- endfor -%}

View File

@ -0,0 +1 @@
{% if text is not empty %}{{ text|replace({'"':'""'})|raw }}{% else %}{{ 'None'|trans }}{% endif %}