Custom datagrid field list sonata admin

993 views
Skip to first unread message

Cassiano Tartari

unread,
Feb 13, 2013, 7:42:47 AM2/13/13
to sonata...@googlegroups.com
Hi everybody!

I want to make a custom display for a integer field of my database. In the datagrid list I want to show the integer values like strings. To create the form I did:

$formMapper->add('tipo', 'choice', array(
            'choices'   => array('0' => 'XXX', '1' => 'YYY'),
            'required'  => false,
            'expanded'  => true,
            'label'     => 'ZZZ',
        ));


Now I want to display in the list XXX and YYY instead of 0 or 1. I tryed without success in the addIndetifier()...

Thanks!

Cassiano Tartari

unread,
Feb 22, 2013, 11:29:38 AM2/22/13
to sonata-users
Just to post the solution:

->add('tipo', 'string', array('template' => 'YourBundle:Entity:index.html.twig'));



And the template is like:

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}

{% block field%}
    <div>
        {% if object.tipo == 1 %}
                Emulação
        {% elseif object.tipo == 0 %}
                Captura
        {% endif %}
    </div>
{% endblock %}



Couldn't do this in a light way... but works like this!

Cassiano Valle Tartari
MSc. Computer Engineer

Tel: +55.48.84474818
Email: fal...@cassianotartari.eng.br
Site: http://www.cassianotartari.eng.br

QR Code



--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users...@googlegroups.com.
To post to this group, send email to sonata...@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages