Hi Mihal,FPF has several modes of operation. In the usual configuration, it scans the result document on POST requests and looks for forms where the "action" matches the current URL. It then re-fills this form using data from the current request (using the global request data object), and looks at the *initial* execution container's validation report object for errors during validation. It can be configured at runtime to work on specific forms (like by ID, or by specific URLs), skip certain fields, populate forms using data you define etc.
Anyway, one major issue with your approach is that you seem to be POSTing to the "post" action, relying on the fact that it loads a slot for the comments which then creates the comment in that special case. That's really, really wrong from a logical point of view, and it also violates the principles of HTTP, not to mention proper separation of concerns. What you should do is post to an "AddComment" action or so, and, on success, *redirect* back to the post page. On error, you would *forward* back to the post page (which contains a slot for the comments form again). However, that won't solve your problem - the validation report is in the AddComment action's execution container, so FPF will not see the validation errors.
That's quite unfortunate, and I'm mildly surprised that nobody has come up with this issue so far. Anyway, in 1.0-HEAD, you have the ability to specify an explicit validation report object for FPF to use instead of the current container's (http://trac.agavi.org/ticket/ 1050). That should solve your problem. So in your AddCommentErrorView, you'd do something like: $this->getContext()->getRequest()- >setAttribute('validation_report', $this->getContainer()- >getValidationManager()->getReport(), 'org.agavi.filter.FormPopulationFilter');
return $this->createForwardContainer('Module', 'ViewPost');
Hope that helps,
- David
On 19.02.2009, at 16:55, Michal Charemza wrote:
Ok, maybe I should be specific with my issue. It is a very similar issue to one I posted previously about (although it is now with different outer/inner actions, hence I suspect my understanding is off...) I have a form that is output in the view of an action, which is itself called as a slot (and so called 'within', if that's the right word, another action). In the Error view of the inner action I now have the following code: $vm = $this->container->getValidationManager(); $errors = $vm->getErrors(); $this->setAttribute('errors', $errors); I can manually output the errors in the template, using $t['errors']. *However* I would prefer to use the FPF. The FPF seems to work in other forms in the app, but not this one. Somehow the errors are 'in'the validation manager, but they don't get to the FPF. Any suggestions?Sorry if I'm being a bit pushy with this issue, but it is slightly driving me crazy... Michal. On 18 Feb 2009, at 07:36, Michal Charemza wrote:I'm having trouble getting validation and the Form Population Filter (FPF) to work as I expect, when the action that processes the form is called as a slot within another action. I wonder if just my understanding of what is going on is wrong. I have some general questions: - What is the data 'flow' of input (say, from the actual $_POST variable), through validation and into an action (where it ends up as the AgaviRequestDataHolder). - What is the data 'flow' of input through validation and into an action called within another action. Is the validation from the *outer* action also applied? - How are these 'flows' different if there is a validation error? - At which stage does the FPF get its data? At what stage do the validation errors get passed to the FPF? Sorry if I'm being a bit vague with the word 'flow', I'm not sure what would be a better word. Michal._______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
