I would like set a value by default in my form.
I am doing this, but didn\'t work:
$builder->add(\'points\', \'hidden\', array(
\'data\' =
If you want to set something by default, set it right on the model object:
$model = new Model;
$model->setPoints(5000);
$form = $this->createForm('type', $model);
Or better yet, if it makes sense, set it right to the model's property or the constructor:
class Model
{
private $points = 5000;
// or
public function __construct()
{
$this->points = 5000;
}
}
use 'empty_data' instead of 'data'
$builder->add('points', 'hidden', array(
'empty_data' => 5000));