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 8409251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:51:21+00:00 2026-06-09T23:51:21+00:00

I run this code to get my select control and it works fine. $builder

  • 0

I run this code to get my select control and it works fine.

    $builder
        ->add('access', 'entity', array(
            'label' => 'Behörigheter',
            'multiple' => true,   // Multiple selection allowed
            'expanded' => true,   // Render as checkboxes
            'property' => 'name',
            'class'    => 'BizTV\ContainerManagementBundle\Entity\Container',
            'query_builder' => function(\Doctrine\ORM\EntityRepository $er) use ($company) {
                $qb = $er->createQueryBuilder('a');
                $qb->innerJoin('a.containerType', 'ct');
                $qb->where('a.containerType IN (:containers)', 'a.company = :company');
                $qb->setParameters( array('containers' => array(1,2,3,4), 'company' => $company) );
                $qb->orderBy('ct.id', 'ASC');

                return $qb;
            }
        )); 

Now I want to be able to customize he label for the checkboxes, I learnt just the other day that by changing property to select_label and defining that function in the entity you can accomplish this, but with this query it doesn’t work.

Is this because I am joining? Is there a way to accomplish it?

This is the code that doesn’t work

    $builder
        ->add('access', 'entity', array(
            'label' => 'Behörigheter',
            'multiple' => true,   // Multiple selection allowed
            'expanded' => true,   // Render as checkboxes
            'property' => 'select_label',
            'class'    => 'BizTV\ContainerManagementBundle\Entity\Container',
            'query_builder' => function(\Doctrine\ORM\EntityRepository $er) use ($company) {
                $qb = $er->createQueryBuilder('a');
                $qb->innerJoin('a.containerType', 'ct');
                $qb->where('a.containerType IN (:containers)', 'a.company = :company');
                $qb->setParameters( array('containers' => array(1,2,3,4), 'company' => $company) );
                $qb->orderBy('ct.id', 'ASC');

                return $qb;
            }
        )); 

In the entity I have:

public function getSelectLabel()
{
    return $this->name . ' (' . $this->parent->getName() . ')';
}

It works fine for another form that has a SELECT (single choice) control, but not for this one…

The error I get is

Fatal error: Call to a member function getName() on a non-object in /var/www/biztv_symfony/src/BizTV/ContainerManagementBundle/Entity/Container.php on line 190

  • 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-09T23:51:23+00:00Added an answer on June 9, 2026 at 11:51 pm

    Oh sorry guys, I had a few objects in there that didn’t have $this->parent defined, I rewrote my name function as follows and it works fine.

    public function getSelectLabel()
    {
        if (isset($this->parent)) {
            return $this->name . ' (' . $this->parent->getName() . ')';
        }
        else {
            return $this->name;
        }
    }
    

    Thanks all!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Java code compiles fine, but when I try to run it I get:
When I run this C code: // Get rid of the CRT and stuff;
When I try to run this code, I get incorrect maximums and minimums. Could
When I run this code to call the Google API, all I get is
If I run this code on IE8 or lower, I get this error: Object
I run this piece of code on Visual C++ 2010 char c[10]; cin.get(&c[0],5); cin.get(&c[2],4);
I have this code and I couldn't run it because i get this error:
I get this error when I run the code below. I have normally used
Please help me with this: This code works fine except for cases in which
Here is my .h file When I run this code and select a text

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.