-1

I am trying to modify the default value of a form field every time the form is updated. I have tried to edit the $form->bind in my processForm (..) but I am unsure how to do so.

Is it possible to get some example code or any approaches to do?

The field name is 'processed' and I am trying to set the value to 'false' - Using Symfony 1.4 (Propel)

aam1r
  • 11
  • 2

2 Answers2

0

In the action, you can directly modify the values from the request before binding them to the form:

$parameters = $request->getParameter('nameofyourform');
$parameters['fieldyouwanttochange'] = 'newvalue';
$yourform->bind($parameters);
kaore
  • 1,288
  • 9
  • 14
0

As an alternative you may modify the doSave() method of your form as suggested by the symfony team.

If you need to modify the saving process itself, sfFormObject::doSave() is usually the best place to do it.

The advantage of this solution is you have all your code related to the form in one class/file.

domi27
  • 6,903
  • 2
  • 21
  • 33