…in the model’s rules function, yet it’s only stripping html tags from the [font=“Courier New”]description[/font], and not in the [font=“Courier New”]name[/font]. [font=“Courier New”]name[/font] is presented as a simple [font=“Courier New”]textField[/font], while [font=“Courier New”]description[/font] is a [font=“Courier New”]textArea[/font].
It seems the filter does work, but as [font=“Courier New”]$form->textField[/font] is being used for the field in question, the input value is also encoded. Despite setting [font=“Courier New”]htmlOptions[‘encode’][/font] to false, it’s still not taking effect. Keeping the [font=“Courier New”]strip_tags[/font] filter, I had to add the [font=“Courier New”]beforeValidate[/font] and [font=“Courier New”]afterValidate[/font] functions to get around this limitation:
/* ******************************************************** */
public function beforeValidate()
{
parent::beforeValidate();
$this->name = CHtml::decode($this->name);
return true;
}
/* ******************************************************** */
public function afterValidate()
{
parent::afterValidate();
$this->name = CHtml::encode($this->name);
return true;
}
Any reason why setting the [font=“Courier New”]encode[/font] attribute to false in [font=“Courier New”]htmlOptions[‘encode’][/font] wouldn’t work…? I was thinking it might be that it’s only true to the field attributes, not its value, though that wouldn’t make much sense as its value is also an attribute…
Note: the reason I wanted to re-encode is to still keep other html entities (other than tags) encoded in the database.