namespace App\Form;
use App\Entity\Booking;
use App\Entity\User;
use App\Entity\Routes;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BookingType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('date')
->add('time')
->add('user', EntityType::class, [
'class' => User::class,
'choice_label' => 'username', // Replace 'username' with the actual property of User to be displayed
])
->add('routes', EntityType::class, [
'class' => Routes::class,
'choice_label' => 'name', // Replace 'name' with the actual property of Routes to be displayed
])
;
// Deliberate error: Typo in method name
$builder
->addr('missingMethod'); // This line has a typo in the method name 'addr' instead of 'add'
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Booking::class,
]);
}
}
I made a CRUD controller using make:crud but when I try to add a new row in my SQL database I get this error: Object of class App\Entity\Routes could not be converted to string
Where is the error and how do I fix it?