1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\FormBundle\Form; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Form\AbstractType; |
6
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
7
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
8
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
9
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* This class represents the type for the MultiLineTextPagePart |
13
|
|
|
*/ |
14
|
|
View Code Duplication |
class MultiLineTextPagePartAdminType extends AbstractType |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @param FormBuilderInterface $builder The form builder |
18
|
|
|
* @param array $options The options |
19
|
|
|
*/ |
20
|
1 |
|
public function buildForm(FormBuilderInterface $builder, array $options) |
21
|
|
|
{ |
22
|
|
|
$builder |
23
|
1 |
|
->add('label', TextType::class, array( |
24
|
1 |
|
'required' => true, |
25
|
|
|
'label' => 'kuma_form.form.multi_line_text_page_part.label.label', |
26
|
|
|
)) |
27
|
1 |
|
->add('required', CheckboxType::class, array( |
28
|
1 |
|
'required' => false, |
29
|
|
|
'label' => 'kuma_form.form.multi_line_text_page_part.required.label', |
30
|
|
|
)) |
31
|
1 |
|
->add('errormessage_required', TextType::class, array( |
32
|
1 |
|
'required' => false, |
33
|
|
|
'label' => 'kuma_form.form.multi_line_text_page_part.errormessage_required.label', |
34
|
|
|
)) |
35
|
1 |
|
->add('regex', TextType::class, array( |
36
|
1 |
|
'required' => false, |
37
|
|
|
'label' => 'kuma_form.form.multi_line_text_page_part.regex.label', |
38
|
|
|
)) |
39
|
1 |
|
->add('errormessage_regex', TextType::class, array( |
40
|
1 |
|
'required' => false, |
41
|
|
|
'label' => 'kuma_form.form.multi_line_text_page_part.errormessage_regex.label', |
42
|
|
|
)) |
43
|
|
|
; |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
1 |
|
public function getBlockPrefix() |
50
|
|
|
{ |
51
|
1 |
|
return 'kunstmaan_formbundle_singlelinetextpageparttype'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param OptionsResolver $resolver |
56
|
|
|
*/ |
57
|
1 |
|
public function configureOptions(OptionsResolver $resolver) |
58
|
|
|
{ |
59
|
1 |
|
$resolver->setDefaults(array('data_class' => 'Kunstmaan\FormBundle\Entity\PageParts\MultiLineTextPagePart')); |
60
|
1 |
|
} |
61
|
|
|
} |
62
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.