@@ 67-80 (lines=14) @@ | ||
64 | $choices = $form->get('link_type')->getConfig()->getOption('choices'); |
|
65 | $firstOption = array_shift($choices); |
|
66 | ||
67 | switch ($firstOption) { |
|
68 | case URLChooserType::INTERNAL: |
|
69 | $attributes['choose_url'] = true; |
|
70 | ||
71 | break; |
|
72 | case URLChooserType::EXTERNAL: |
|
73 | $attributes['placeholder'] = 'https://'; |
|
74 | $constraints[] = new Url(); |
|
75 | ||
76 | break; |
|
77 | case URLChooserType::EMAIL: |
|
78 | $constraints[] = new Email(); |
|
79 | ||
80 | break; |
|
81 | } |
|
82 | ||
83 | $form->get('link_type')->setData($firstOption); |
@@ 48-62 (lines=15) @@ | ||
45 | if ($linkType) { |
|
46 | $form->remove('link_url'); |
|
47 | ||
48 | switch ($linkType) { |
|
49 | case URLChooserType::INTERNAL: |
|
50 | $attributes['choose_url'] = true; |
|
51 | ||
52 | break; |
|
53 | case URLChooserType::EXTERNAL: |
|
54 | $attributes['placeholder'] = 'https://'; |
|
55 | $constraints[] = new Url(); |
|
56 | ||
57 | break; |
|
58 | case URLChooserType::EMAIL: |
|
59 | $constraints[] = new Email(); |
|
60 | ||
61 | break; |
|
62 | } |
|
63 | ||
64 | $form->add('link_url', TextType::class, array( |
|
65 | 'label' => 'URL', |