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

typo3 at litedesigns.nl typo3 at litedesigns.nl
Fri Mar 30 09:06:13 CEST 2012


Hi Jochen,

Thanks for the suggestion, i will take a look at custom validators.

To be more clear about my model:

Company
|- FieldA
|- FieldB
|- Address (Model)
|- BillingAddress
   |- FieldC
   |- FieldD
   |- Address (Model)

And address:
Address
|- Street
|- Housenumber
|- City
|- Etc

Since both Company and BillingAddres have an Address, i want to validate
both  Address instances in my single form differently.

The Company->Address fields need to be required, the
BillingAddress->Address fields must be optional.

Another way to look at it would be like with an eCommerce website when a
customer registers or buys something:

Customer
|- Address
|- ShippingAddress

Where the Customer->Address is where the customer lives and the
ShippingAddress is where the products will be delivered.

I will report back my findings with the custom validators, although i'm
still not entirely sure how Company->Address fields can be set required
and the BillingAddress->Address fields optional. But as said, i will first
look into the custom validators :)

Kind regards,
Tim

> Hi Tim,
>
>> 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.
>
> So, you have two distinct properties in your Company class: one
> referencing the address and one referencing the billingAddress? A custom
> BillingAddressValidator attached to the billingAddress might help.
>
> -Jochen
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>



More information about the TYPO3-project-typo3v4mvc mailing list