Symfony form pills – Value object
Suppose that we have a value object or, more in general, an object where its data has been set in the constructor
1
2
3
4
5
6
7
8
9
10
11
|
class Foo
{
protected $bar;
protected $foobar;
public function construct($bar, $foobar)
{
// ....
}
}
|
and its FormType
1
2
3
4
5
6
7
8
9
10
11
|
class FooType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('bar')
->add('foobar');
}
// ...
}
|
Let’s assume that bar and foobar are taken from HTTP POST values (so, basically, we need those values to be posted…