1 | <?php |
||
16 | class SubscriberForm extends FormElement |
||
17 | { |
||
18 | public function getClassName() |
||
19 | { |
||
20 | return 'FSi\FixturesBundle\Entity\Subscriber'; |
||
21 | } |
||
22 | |||
23 | public function getId() |
||
24 | { |
||
25 | return 'subscriber_form'; |
||
26 | } |
||
27 | |||
28 | public function getName() |
||
29 | { |
||
30 | return 'admin.subscriber.name'; |
||
31 | } |
||
32 | |||
33 | public function getSuccessRoute() |
||
34 | { |
||
35 | return 'fsi_admin_list'; |
||
36 | } |
||
37 | |||
38 | public function getSuccessRouteParameters() |
||
39 | { |
||
40 | return ['element' => 'subscriber']; |
||
41 | } |
||
42 | |||
43 | protected function initForm(FormFactoryInterface $factory, $data = null) |
||
44 | { |
||
45 | $builder = $factory->createNamedBuilder( |
||
46 | 'subscriber', |
||
47 | TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\FormType', 'form'), |
||
48 | $data, |
||
49 | ['data_class' => $this->getClassName()] |
||
50 | ); |
||
51 | |||
52 | $builder->add( |
||
53 | 'email', |
||
54 | TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\EmailType', 'email'), |
||
55 | ['label' => 'admin.subscriber.list.email'] |
||
56 | ); |
||
57 | |||
58 | $builder->add( |
||
59 | 'created_at', |
||
60 | TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date'), |
||
61 | [ |
||
62 | 'label' => 'admin.subscriber.list.created_at', |
||
63 | 'widget' => 'single_text' |
||
64 | ] |
||
65 | ); |
||
66 | |||
67 | $builder->add( |
||
68 | 'active', |
||
69 | TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\CheckboxType', 'checkbox'), |
||
70 | ['label' => 'admin.subscriber.list.active'] |
||
71 | ); |
||
72 | |||
73 | return $builder->getForm(); |
||
74 | } |
||
75 | } |
||
76 |