[TYPO3-mvc] Complex array validation

Claus Due claus at wildside.dk
Mon Feb 6 21:52:47 CET 2012

Hi Jacob,

> A participating person has two attributes, name and age and a wish has 3 attributes, a house, an arrival and departure date, so AFAIK I can't map these fields directly to my inquiry model, and get them validated this way, as the frontend users can add an arbitrary number of persons and wishes.

Note here: if you use the rewritten property mapper you have to allow the creation of new objects. I'm sorry this is just a hint - you should be able to find how on the Extbase Wiki (I don't recall exactly how this is done and would rather not risk giving you incorrect info).

> So I'm currently sending the wish and person data in separate parts of my form array like this:
> <f:form.textfield name="wishes[house][] />
> <f:form.textfield name="wishes[arrival][] />
> <f:form.textfield name="wishes[departure][] />
> <f:form.textfield name="persons[name][] />
> <f:form.textfield name="persons[age][] />
> Now I would like to get these data validated correctly and trigger the errorAction correctly whenever one or the wishes or persons doesn't match my model validation rules.

This is not the ideal solution. You should be using "property" and have an assigned FormObject, otherwise validation will be a pain.

Perhaps you can use this:


It does exactly what you need: adds related objects as an ObjectStorage of other DomainObjects while preserving full validation and form token generation. Rather than doing it like IRRE in the backend (add one item, fill out, add another etc) all the requested items are immediately added and ready to be filled.

Included is a selector to allow the user to dynamically set the number of items to fill out.

Generally speaking you may find a lot of what you need already included in FED ;)

> I've thought of using the propertymapper in my controller, but I can't really figure out how to trigger errors correctly - so I would like to know if there is another (and better) way of mapping properties to the form and sending it to the controller.

You want to avoid this :) but if you can't stay away from that solution let me know; I may have some tips for you.


More information about the TYPO3-project-typo3v4mvc mailing list