[TYPO3-mvc] different validations for same model used twice in a single form

typo3 at litedesigns.nl typo3 at litedesigns.nl
Thu Mar 29 16:14:57 CEST 2012


Hi List,

I'm working on a single (Extbase / Fluid) form with multiple objects,
based on this thread:
http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2012-March/012070.html

My form works, all objects are validated by Extbase and i can 'write the
values' back into the fields if the user submits the form and not the
entire form is valid yet. This way the user does not need to enter all
values again.

Some info about the models:
I have a Company, which has some fields of it's own and a 1:1 relation
with an Address. But the Company also has an optional BillingAddress. The
BillingAddress has some fields of it's own, but also has a 1:1 relation
with an Address.

The Address model has some fields like: street, housenumber, zip, etc

The BillingAddress fields and it's related Address fields are hidden in
the form initially and if the information needs to be different from the
Company information, the user can show these fields (with javascript).

How can i make the Company->Address fields required and the
BillingAddress->Address fields optional? Both Company and BillingAddress
obviously use the same Address Model (to avoid duplicate code) and i can
only set one annotation per property.

I would love to use 'an extbase solution' and not validate both addresses
with for example javascript or manually in my Controller.

Any hints which way i should go are much appreciated. I don't need a
complete solution. Some hints, best practices or resources would be
awsome!

Kind regards,
Tim



More information about the TYPO3-project-typo3v4mvc mailing list