3

I have a form type

$subscriptions = []//array of Subscription

$builder
    ->add('subscription', ChoiceType::class, [
        'choices' => $subscriptions,
        'choice_label' => 'code'
    ])
;

I have the error:

Cannot read index "subscription" from object of type "App\ValueObject\Company" because it doesn't implement \ArrayAccess.

Company is a value object that contain a $subscription property (Subscription)

class Company
{
    private Subscription $subscription;

    // ......
}

Do you know why I have the error? I want to let the user choose between some subscriptions that are VO from another API

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sancho
  • 1,288
  • 2
  • 25
  • 50
  • seems like Symfony is trying to use your Company Subscription as the choices, can you share the whole code of your form ? – Snroki Feb 01 '21 at 10:02

0 Answers0