I have an accounting app in Symfony 2.7.x.
When creating a new transaction, the total amount in the transaction may be split across multiple categories but I need to validate that the total of the category amounts is not greater than the total of the transaction.
ie- Transaction:
Payee: Exxon
Amount: $100.00
Categories:
Name: Snacks
Amount: $45.00
Name: Gasoline
Amount: $55.00
Each category is a separate entity in the database as well.
So if the user changed Gasoline to $65.00, the form should fail validation.
I've researched Symfony 2 form validation but everything I find seems to revolve around Constraint Annotations on single properties of an object and not across multiple entities.
I'm assuming I need to set up a validation service, but I'm struggling with how to set it up and to get it to trigger on the appropriate form.