By using Symfony validators
How to prevent some HTML tags like
<input></input>
<textarea><textarea>
from being entered in input field and saved in database?
Symfony3 - How to validate HTML tags
1.3k Views Asked by Basel Issmail At
2
There are 2 best solutions below
0

also you can use strip_tags
php function in your setter function to prevent html tags, also you can pass some allowed tags to this function.
public function setText()
{
$this->text = strip_tags($text);
return $this;
}
You can assert using regex on text/string properties in your entity. For example, this should block any HTML tags in a string:
This should check for input and textarea elements: