Question

What is or might be the best practice to integrate the HTMLPurifier in Zend Framework 2? The goal is to filter Zend Form Elements and input fields, which where not generated with Zend Form.

How would you do this?

Was it helpful?

Solution

From my point of view I would say you can create a new filter. If Purifier were already a 'part' of Zend then it might be name Zend\Filter\HtmlPurifier. That's where I see it fitting the most.

You could also make it a Validator (Zend\Validator\HtmlPurifier) so you can tell if a piece of text 'passes' or not. Depends on what you want to do.

If you want to reject bad input, use the validator path. If you want to filter out bad input use the filter path.

After you've made your Zend filter/validator, use it like you would any other filter/validator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top