I have a form where an XML file is uploaded. After the form is submitted I have to check the content of a pair of tags in the XML file. If the content of the tags is different from some expected, an error should be shown next to the form.
I don’t know exactly how to organize this code, any help?
tags: prevalidation, postvalidation
You have several places to perform this check:
I prefer the custom validator because if you have to re-use the form somewhere else you won’t have to re-implement the logic of checking the xml.
So in your sfForm class, add a custom validator to your file widget:
And inside your new validator at
/lib/validator/customXmlFileValidator.class.php:Do not forget to clear your cache
php symfony ccand it should be ok.