Setting up defaults to edit form
Setting up defaults in factory component / form is wrong. What's the right way to do so?
class FooPresenter extends BasePresenter
{
protected function loadItem($id)
{
$item = $this->getContext()->itemService->find($id);
if (!$item) {
$this->flashMessage("Item with id $id does not exist", 'error');
$this->redirect('default'); // aka items list
}
return $item;
}
protected function createComponentRecordForm()
{
$form = new Form;
$form->addText(...);
// ...
}
public function actionEdit($id)
{
$item = $this->loadItem($id);
$defaults = $this->someMagicHere($item);
$this['recordForm']->setDefaults($defaults);
}
}