I want to create a validator similar to the way GitHub handles deleting repositories. To confirm the delete, I need to enter the repo name. Here I want to confirm delete by entering the entity property “name”. I will either need to pass the name to the constraint or access it in some way, how do I do that?
I want to create a validator similar to the way GitHub handles deleting repositories.
Share
you could indeed use a validator constraint to do that:
1: Create a delete form (directy or using a type):
2: Add a public property
comparisonNameinto your entity. (or use a proxy object), that will be mapped to the corresponding form field above.3: Define a class level, callback validator constraint to compare both values:
4: Display your form in your view:
5: To verify that the delete query is valid, use this in your controller: