Vychozí data pro editační formulář
Plnit data rovnou v továrničce komponenty / formuláře je špatně. Jak je to dobře?
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);
}
}
Comments 
Patrik Votoček | 28. 2. 2012, 1:51 | comment
@newPOPE: u defaults je to více méně jedno. Nicméně můžeš chtít do formuláře plnit třeba itemy pro selectbox a na to je v render* pozdě.
newPOPE | 27. 2. 2012, 21:46 | comment
Som si vedomy, ze je to asi jedno ale zda sa mi lepsie plnit defaults v render* ?.