39 lines
1006 B
PHP
39 lines
1006 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Entity\{Brand, Fpu, Socket};
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
|
|
class FpuType extends AbstractType {
|
|
use BrandCategoryTrait;
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder
|
|
->add('socket', EntityType::class, [
|
|
'class' => Socket::class,
|
|
'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('s')->orderBy('s.name', 'ASC'),
|
|
])
|
|
->add('brand', EntityType::class, [
|
|
'class' => Brand::class,
|
|
'query_builder' => self::filterBrands('fpu'),
|
|
])
|
|
->add('series')
|
|
->add('model')
|
|
->add('clockSpeed')
|
|
->add('count')
|
|
->add('notes');
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver): void
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => Fpu::class,
|
|
]);
|
|
}
|
|
}
|