Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:56:27+00:00 2026-06-04T09:56:27+00:00

I have an entity Transaction with numerous status codes. I want the user to

  • 0

I have an entity Transaction with numerous status codes.
I want the user to be able to see these status codes as strings in SonataAdmin. The user should also be able to filter on the basis of these status codes.

Entity Transaction 
{
    const TRANSACTION_STATUS_WAITING = 1;
    const TRANSACTION_STATUS_PENDING = 2;
    const TRANSACTION_STATUS_CONFIRMED = 3;

   /**
     * Set status
     *
     * @param smallint $status
     */
    public function setStatus($status)
    {
        $this->status = $status;
    }

    /**
     * Get status
     *
     * @return smallint 
     */
    public function getStatus()
    {
        return $this->status;
    }

    public function getStatusAsString()
    {
        switch($this->status){
            case(self::TRANSACTION_STATUS_WAITING): return "Waiting for Merchant";
            case(self::TRANSACTION_STATUS_PENDING): return "Pending Confirmation";
            case(self::TRANSACTION_STATUS_CONFIRMED): return "Confirmed";
        }
    }
}

I have configured my Sonata List Mapper like this:

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('id')
        ->add('statusAsString', null, array('sortable' => true, 'label' => 'Status'))
}

which works perfectly fine:

However I am unable to use the same as a Filter.

If I try this:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('user')
        ->add('status') // Works well 
        ->add('statusAsString', null, array('label' => 'Status')) // Doesn't work: 
    ;
}

This doesn’t work. It gives the following error ->

Notice: Undefined index: statusAsString in ..../Sonata\DoctrineORMAdminBundle\Guesser\FilterTypeGuesser.php 

How can I make it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:56:29+00:00Added an answer on June 4, 2026 at 9:56 am

    This worked as a temporary solution for me. If anyone has a better solution, please share.

    $datagridMapper
           ->add('status', 'doctrine_orm_string', array(),
                 'choice', array('choices' => Transaction::getStatusList())
           );
    

    In the entity

    public static function getStatusList()
        {
            return array(
                self::TRANSACTION_STATUS_WAITING => "Waiting",
                self::TRANSACTION_STATUS_PENDING_CONFIRMATION => "Pending Confirmation",
                self::TRANSACTION_STATUS_CONFIRMED => "Confirmed",
                self::TRANSACTION_STATUS_PAYMENT_REQUESTED => "Payment Requested",);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a User class marked as entity which also implements UserDetails. I want
Let's say you have a domain entity User and you want to support the
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
I have an entity loaded by Hibernate (via EntityManager ): User u = em.load(User.class,
I have three methods: public void Save<T>(T entity) { using (new Transaction()) { Session.Save(entity);
I have following Entity Framework Logic, and I want to translate to Stored Procedure,
I have the following @OneToOne relation: @Entity @Table(name=USER) public class User implements Serializable{ private
I have table name Transaction in the DB. I want to have 2 subclasses
I have table name Transaction in the DB. I want to have 2 subclasses
I'm using Entity Framework 4.1 and have a seemingly simple requirement: I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.