I am attempting to use a data transfer object with a Symfony form. The form type I'm using looks like this:
class SuggestedEventPricingFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$localCurrency = $builder->getData()->getCurrencyCode();
$builder
->add('pricingScheme', TextType::class, ['required' => true])
->add(
'eventPricing',
EventPricingFormType::class,
['error_bubbling' => false, 'local_currency' => $localCurrency]
)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults(['data_class' => SuggestedEventPricing::class]);
}
}
... and when I command-click on SuggestedEventPricing in PHPStorm, I am correctly taken to the class definition, so I know my use statement in the form type is correct.
But I still get this message when trying to load the form:
Class "AppBundle\Value\SuggestedEventPricing" not found. Is the "data_class" form option set correctly?
Any ideas for next steps I can take in debugging this?
Well, today I learned something: PHPStorm will happily sent you to a file that has the wrong namespace declared at the top of it.
Changing the namespace at the top of the class file I wanted to use (along with the reference in the
usestatement at the top of my form type) fixed this up quickly. I hope this helps someone else. (Greetings, future Googler!)