I'm trying to modify the content of the response from some actions in Symfony 1.4.
When I process some forms, and after some conditions, in processForm method (the one called for form binding, and giving the final result of the form processing operation).
I tried
function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind(...);
// ... some validations/operations ...
$cont = $this->getResponse()->getContent();
$this->getResponse()->setContent("MODIFICATION!" . $cont);
$this->getResponse()->sendContent();
}
but this currently sends me a "Cannot modify header information - headers already sent" error...
Is this at all possible? or am I talking nonsense? Any ideas?
Thank you!
EDIT: What I am trying to do is the following.
In the executeNew action, I have to make some validations. All the field specific validations are correctly done with the corresponding form validators.
But there is a validation that takes into account the value of 2 of the fields at the same time, not just one of them. So, haven't found a way to make a validator for this two fields at the same time, I decided to validate by overriding the isValid method of the form, calling the parent::isValid method to, and validating my 2-field condition here too. When validation fails, I return false, as isValid() should. But also, I haven't found how to write the Error message near the form when this particular error happens. That's why I wish to alter the content of the Response, so I can add a customized error message for this particular error condition, only when it happens...
Hope this helps to clarify my post...