The AgaviFromPopulationFilter is handy to re-fill a form after validation failed and the user needs to check the values again (without refilling them by hand again).

But the FormPopulationFilter (FPF) is also capable of pre-filling forms.

Just get into your view and add the following:

1
2
3
4
5
6
7
8
9
10
if ('read' == $this->getContext()->getRequest()->getMethod()) {
$this->getContext()->getRequest()->setAttribute('populate',
new AgaviParameterHolder(
array(
'name' => 'Test Entry',
'description' => 'This is a short description'
)
), 'org.agavi.filter.FormPopulationFilter'
);
}

and your Formfields 'name' and 'description' will be prefilled.

I added the check for 'read' method, since you don't want to auto populate in the case you submitted the data.

The template looks tidy now:

1
2
<input type="text" name="name"/>
<textarea name="description"></textarea>

Thanks to veikko and saracen.