allowing csv rendering for custom fields

This commit is contained in:
Marc Ducobu
2015-02-17 15:01:12 +01:00
parent 77247de990
commit 47a9a29236
7 changed files with 27 additions and 9 deletions

View File

@@ -187,7 +187,7 @@ class CustomFieldChoice implements CustomFieldInterface
* @param CustomField $customField
* @return string html representation
*/
public function render($value, CustomField $customField)
public function render($value, CustomField $customField, $documentType = 'html')
{
//extract the data. They are under a _choice key if they are stored with allow_other
$data = (isset($value['_choices'])) ? $value['_choices'] : $value;
@@ -198,8 +198,13 @@ class CustomFieldChoice implements CustomFieldInterface
$choices[] = array('name' => $value['_other'], 'slug' => '_other');
}
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.html.twig';
if($documentType == 'csv') {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig';
}
return $this->templating
->render('ChillCustomFieldsBundle:CustomFieldsRendering:choice.html.twig',
->render($template,
array(
'choices' => $choices,
'selected' => $selected,

View File

@@ -43,7 +43,7 @@ interface CustomFieldInterface
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
* @return string an html representation of the value
*/
public function render($value, CustomField $customField);
public function render($value, CustomField $customField, $documentType = 'html');
public function getName();

View File

@@ -90,7 +90,7 @@ class CustomFieldText implements CustomFieldInterface
));
}
public function render($value, CustomField $customField)
public function render($value, CustomField $customField, $documentType = 'html')
{
return $this->templating
->render('ChillCustomFieldsBundle:CustomFieldsRendering:text.html.twig', array('text' => $value));

View File

@@ -67,7 +67,7 @@ class CustomFieldTitle implements CustomFieldInterface
));
}
public function render($value, CustomField $customField)
public function render($value, CustomField $customField, $documentType = 'html')
{
return $this->templating
->render('ChillCustomFieldsBundle:CustomFieldsRendering:title.html.twig',