Thanks for any help with this, I’m very new to the Symfony framework so just trying to get my head around it.
I want to be able to intercept a submitted form from the admin area and modify the data.
Here’s what I’ve got so far (in basic form)..
/apps/backend/modules/proposition/actions/action.class.php
class propositionActions extends autoPropositionActions {
public function executeCreate(sfWebRequest $request) {
// modify the name
$name = $request->getParameter('name');
$name = $name . ' is an idiot';
$request->setParameter('name', $name);
return parent::executeCreate($request);
}
}
My form does contain a name field:
/apps/backend/modules/proposition/config/generator.yml
generator:
class: sfDoctrineGenerator
param:
model_class: Proposition
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: proposition
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
form:
display: [name, icon, overview, published]
I’m not sure if that’s the file you need to see of not, but it’s definitely in the HTML:
<input type="text" id="proposition_name" name="proposition[name]">
When I submit the form it just saves my name. I want it to save my name appending ‘ is an idiot’.
Many thanks
I think you are on the right track Peter, but modifying the
$requesttoo late for it to have any effect.You could do this sort of modification of inbound data in the “doClean” part of the Form’s validator.
Or, if you have special processing to do, it might make more sense to override the generated
processForm()function. Just copy it out ofcache/frontend/dev/modules/autoProposition/actions/actions.class.phpinto yourapps/backend/modules/proposition/actions/action.class.phpand start hacking.