Hi,
In this PR, I'd like to introduce the possibility to use setDefaults later in the Component model life cycle than in the constructor. Currently it is possible to set values only before the component is attached, which makes the Multiplier a bit tough to use with a typical Nette application life cycle.
With this PR, it is possible to:
class RecipePresenter {
public function actionDetail($recipeId) {
$recipe = [
'name' => 'hot-dog',
'steps' => [
['description' => 'put sausage into boiling water'],
['description' => 'make hole into a bread roll'],
['description' => 'optional: add ketchup or mustard into bread roll'],
['description' => 'insert sausage'],
]
];
$form = $this['recipeForm'];
$form->setDefaults($recipe);
}
public function createComponentRecipeForm() {
$form = new Form();
$form->addText('title', 'Recipe name');
$form->addMultiplier('steps', 'Steps', function($container) {
$container->addTextarea('description');
});
return $form;
}
}
Note: The first commit is not neccessary for this PR. As I was investigating, I found out that the removed functionality does not seem to bring any value and with re-initialization in mind, I wanted to reduce needles instances creation
Hi, In this PR, I'd like to introduce the possibility to use setDefaults later in the Component model life cycle than in the constructor. Currently it is possible to set values only before the component is attached, which makes the Multiplier a bit tough to use with a typical Nette application life cycle.
With this PR, it is possible to:
Note: The first commit is not neccessary for this PR. As I was investigating, I found out that the removed functionality does not seem to bring any value and with re-initialization in mind, I wanted to reduce needles instances creation