ChoiceType with ValueObject from API

Viewed 37

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

0 Answers
Related