[TYPO3-mvc] fun with validation.
Patrick Schriner
patrick.schriner at diemedialen.de
Fri Feb 8 10:15:26 CET 2013
Note: all this applies to Extbase 1.3, I'm not sure if the behaviour has
changed since - but I'd guess not.
When an error is found, errorAction will try to redirect to the referring
controller action "A".
If any of the arguments passed can't be validated (e.g. one of the
parameters doesn't have @dontvalidate, or the parameter names don't match,
or an object is not set as = NULL) that validation error will again
trigger errorAction - which will now try to redirect to the exact same
action "A" - and run into the iteration loop.
So: if you have a form the first action should not require any valid
parameters.
Assuming you have multiple actions any further action should not have
@dontvalidate (imho), but you can check if the object is NULL:
public function createAction(Tx_Bla_Domain_Model_Bla $newBla= NULL) {
if ($newBla == NULL) {
$this->flashMessageContainer->flush();
$this->redirect('new');
}
...
This will prevent error messages when you reopen an "old" link to that
action as the __referrer parameter will be missing if the form was POSTed
but now only the url is used. (That's probably your watched behaviour)
Patrick
On Fri, 08 Feb 2013 10:01:18 +0100, Toke Herkild <th at t3cms.dk> wrote:
> Hi all,
>
> I've got some fun with validators:
>
> In the model I've the following:
>
> /**
> * position
> *
> * @var string
> * @validate StringLength(minimum=1, maximum=254)
> */
> protected $position;
>
> In the controller:
>
> /**
> * create...
> * ..
> */
>
> And new :
> /**
> * create...
> * ..
> *@dontvalidate tModel
> */
>
> Now, this should be fine... but, I'm submitting the form using ajax, and
> if I add validation, and only clearcache, it works like a charm. But if
> I reload page and clear browser cache, then I get the "101 iterations"
> error.
>
> I've been through 10 pages of google search results for extbase and
> validate/dontvalidate, and I'm still no closer to understanding why it
> somewhat works and then again it really doesn't.
>
> Anyone got a good idea as to where to look ?
>
> Regards,
> Toke
--
Patrick Schriner
More information about the TYPO3-project-typo3v4mvc
mailing list