0

If you got for example the following Entities and relations:

PurchasedService * ---> 1 Service * ---> 1 ServiceCategory

how can you create a formType listing all entries from ServiceCategory within PurchasedServiceType?

As:

$builder
        ->add('servicecategory', 'entity', array(
            'class' => 'InvoicingBundle:ServiceCategory',
            'query_builder' => function(EntityRepository $er) {
                return $er->createQueryBuilder('sc')
                    ->orderBy('sc.serviceCategoryName', 'ASC');
            },
        ))

Results in ERROR:

Neither the property "servicecategory" nor one of the methods "getServicecategory()", "isServicecategory()", "hasServicecategory()", "__get()" exist and have public access in...

I would expect to call the Entity ServiceCategory directly?

ZeroSpace
  • 119
  • 1
  • 7

1 Answers1

0

And it should. But I feel that you missed the namespace. In your case you have:

'class' => 'InvoicingBundle:ServiceCategory',

Always the InvoicingBundle is localized in some directory - you should have src/{theMissingDirectory}/InvoicingBundle/Entity/ServiceCategory , so the pattern is:

'class' => '{theMissingDirectory}InvoicingBundle:ServiceCategory',

in example:

'class' => 'AcmeInvoicingBundle:ServiceCategory',

Please try in this way and it should work.

Regards,

Piotr Pasich
  • 2,639
  • 2
  • 12
  • 14