Pre-Populating Formfields in Agavi
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:
2
3
4
5
6
7
8
9
10
$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:
2
<textarea name="description"></textarea>
Messages
im ready
thegangiwanttobeonhereisthuglife
me gustaria jugar gta san andreas gratis
che grac
Chce grac xD
wazaaaa
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'
);
}


