OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Custom field decorating

This topic contains 7 replies, has 3 voices, and was last updated by  Pavel Levin 6 years, 3 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #24773

    Pavel Levin
    Participant

    Hello!
    I have two questions.
    How to disable formatting numeric field in the list? The field value is displayed with a separator – 10,001,152 instead 10001152.
    On detail page field shows correctly.
    How to apply custom decorator to my field? I want to display a numeric field as an external link.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #24774
    Yevhen Shyshkin
    Yevhen Shyshkin
    Participant

    Hello, Pavel Levin.

    > How to disable formatting numeric field in the list? The field value is displayed with a separator – 10,001,152 instead 10001152.
    If you are talking about the grids, then you can simply render it as string – so, numeric formatter will not be applied. To do that simply remove “frontend_type” from column declaration.

    > How to apply custom decorator to my field?
    It depends on where you are going to use it. The simplest way is to create twig extension with formatter function and use it anywhere you need – on view page, in grid inside twig template etc.

    #24775

    Pavel Levin
    Participant

    Hello, Yevhen!
    I have created a field in the Contacts module with a tool in the admin panel (Main menu -> System -> Entities). It does not contain “frontend_type”.
    Field page
    Grid

    I created an extension for Twig. Where is template for decorate client_id field on contact module view page? What is “right way” to do it?

    #24776
    Yevhen Shyshkin
    Yevhen Shyshkin
    Participant

    Now I see. This field has type “integer”, so integer formatting applying to it everywhere. I think there is no easy way to customize it from UI because formatter uses locale defined format, and it automatically changed when you are changing locale.

    Fix from UI – you can use type “string” instead of “integer”, but in this case value will be stored as string, not as integer, so you will not be able to filter of sort by numeric value.

    Another option – create datagrid listener for this specific grid and manually set frontend_type to “string”, like here: https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/SalesBundle/Resources/config/datagrid.yml#L44. Actually, in this listener you can customize anything in this grid – so, it’s the most flexible solution.

    #24777
    Dima Soroka
    Dima Soroka
    Keymaster

    We will implement type “Number” to cover this specific case, please keep looking into upcoming releases.

    #24778

    Pavel Levin
    Participant

    Dmitry, thanks, I’ll wait for the release.
    Yevhen, give an example implementation for my task.
    Custom fields decorating is very important issue and an example will be useful for many users.

    #24779
    Yevhen Shyshkin
    Yevhen Shyshkin
    Participant

    Here is example of grid listener – https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/CallBundle/EventListener/Datagrid/CallListener.php#L32. It does not exactly that you need, but main idea is the same – it simply customize datagrid configuration.

    #24780

    Pavel Levin
    Participant

    Hello!
    I created event listener for oro_datagrid.datagrid.build.before event, but $event->getConfig[‘columns’] doesnt contains my custom field.

Viewing 7 replies - 1 through 7 (of 7 total)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No