/
SimpleArrayType.php
52 lines (47 loc) · 1.49 KB
/
SimpleArrayType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace EmanueleMinotto\SimpleArrayBundle\Form\Type;
use EmanueleMinotto\SimpleArrayBundle\Form\DataTransformer\SimpleArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class SimpleArrayType extends AbstractType
{
/**
* Builds the form.
*
* This method is called for each type in the hierarchy starting from the
* top most type. Type extensions can further modify the form.
*
* @param FormBuilderInterface $builder The form builder.
* @param array $options The options.
*
* @see FormTypeExtensionInterface::buildForm()
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addViewTransformer(new SimpleArrayTransformer());
}
/**
* Returns the name of the parent type.
*
* You can also return a type instance from this method, although doing so
* is discouraged because it leads to a performance penalty. The support
* for returning type instances may be dropped from future releases.
*
* @return string
*/
public function getParent()
{
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\TextType'
: 'text';
}
/**
* Returns the name of this type.
*
* @return string
*/
public function getName()
{
return 'simple_array';
}
}