P
P
Prudkovski2014-11-20 12:28:12
symfony
Prudkovski, 2014-11-20 12:28:12

How to correctly handle entity parameter output?

Good afternoon.
Question for the symphonists.
There is a table in which crm throws off the address in the format "value, , , value2, value3 ..." - roughly speaking, a string with separators. The task in the output of this entity parameter in the template is to remove empty values.
I came up with 3 solutions.
1) In the entity itself, in the parameter getter
2) In the controller, before sending the object, process it (IMHO is not correct)
3) Maybe somehow in the template you can use explode?
How to choose the right option, taking into account the fact that in the future crm may write it to the database in a different format and, accordingly, you will have to change the output processing, but all other entity parameters are displayed as written, i.e. only one entity parameter needs to be processed.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2014-11-20
@prudkovski

If you are using twig, then you can get rid of split, for example:

{%  set items = "value, , ,value2,value3..."  %}
{%  for item in items|split(',')  %}
        {{  item  }}
{%  endfor  %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question