ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 2 replies, has 2 voices, and was last updated by thinh2010 thinh2010 2 months, 1 week ago.

  • Creator
    Topic
  • #37618
    thinh2010
    thinh2010
    Participant

    Hi,

    I extended User entity. Now I want to create a fucntion getCustomName() to return my custom name for user
    and then I can call it via twig by user.customName

    Do you know how can I do that?

    This is my information about the system I use

    Application Type: OroPlatform
    Application Version: 2.0.*
    Application Edition: Community

    OS, name and version: Ubuntu 14.04 64bit
    Web server, name and version: Apache,
    Database, name and version: MarialDB 10.0.21
    PHP, version: 5.6.30

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #37853

    Hi,

    1. If you need to add some additional filed to entity User, you can create migration in custom bundle to create a extend field for entity.
    Example for field ‘title’ of user entity:
    https://github.com/oroinc/platform/blob/2.3/src/Oro/Bundle/UserBundle/Migrations/Schema/v1_9/OroUserBundle.php

    To add field CustomName you need create migration like this

    As result new column ‘customName’ will be created in oro_user table.
    Entity User will have property $customName and methods getCustomName and setCustomName.

    Value is available in twig template by user.customName.
    Also field customName is added on user edit page.

    2. If you need some method which will return value based on other properties of entity user and it should be available in twig template, in this case better create twig extension and use it.

    #39090
    thinh2010
    thinh2010
    Participant

    Hi,

    Thanks for your reply, I will try with twig extension

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

You must be logged in to reply to this topic.