1// src/Form/Type/OrderType.php
2namespace App\Form\Type;
3
4use App\Form\Type\ShippingType;
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7
8class OrderType extends AbstractType
9{
10 public function buildForm(FormBuilderInterface $builder, array $options)
11 {
12 $builder
13 // ...
14 ->add('shipping', ShippingType::class)
15 ;
16 }
17
18 // ...
19}
20
1// src/Form/Type/ShippingType.php
2namespace App\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
6use Symfony\Component\OptionsResolver\OptionsResolver;
7
8class ShippingType extends AbstractType
9{
10 public function configureOptions(OptionsResolver $resolver)
11 {
12 $resolver->setDefaults([
13 'choices' => [
14 'Standard Shipping' => 'standard',
15 'Expedited Shipping' => 'expedited',
16 'Priority Shipping' => 'priority',
17 ],
18 ]);
19 }
20
21 public function getParent()
22 {
23 return ChoiceType::class;
24 }
25}
26