-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
FormactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)
Milestone
Description
The usage of the empty_data
option for forms should be documented. empty_data
allows to set the data set in the form when it is bound and setData()
wasn't called before.
By default, this is null
or, if data_class
is set, a new instance of that given class (created by using a no-args constructor).
The option can be overridden by setting a static value (1) or by setting a closure (2), that receives a FormInterface
instance as first argument. (2) should be preferred, as it only creates objects on demand.
(1)
public function getDefaultOptions()
{
return array(
'empty_data' => new User($this->someDependency)
);
}
(2)
public function getDefaultOptions()
{
return array(
'empty_data' => function (FormInterface $form) {
return new User($form->get('username')->getData());
}
);
}
Metadata
Metadata
Assignees
Labels
FormactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)