Max, I want to remove HTML tags from text fields, 1x after loading from the DB and 1x before saving to the DB. Where or how do I use strip_tags for this?
Forums
CF8 - Remove HTML Tags from Text Fields
Use a PHP action, and set the updated value in a var then use that var in the field Value setting:
In PHP:
and in field Value:
In PHP:
$this->set("stripped", strip_tags($this->get("value")));
and in field Value:
{var:stripped}
Ok, i need more help:
Page4 -> DB Read Action -> Field: text12 (with html tags...)
PHP: $this->set("stripped", strip_tags($this->get("text12")));
OR
PHP: $this->set("stripped", strip_tags($this->data("text12")));
Textarea: Field Name: text12 (with html tags)
DB Save Action: text12={data:text12}
Page4 -> DB Read Action -> Field: text12 (with html tags...)
PHP: $this->set("stripped", strip_tags($this->get("text12")));
OR
PHP: $this->set("stripped", strip_tags($this->data("text12")));
Textarea: Field Name: text12 (with html tags)
DB Save Action: text12={data:text12}
Ok, I'll try another solution. I simply change the affected fields on the first page. This means the correct data is available on page 4.
$this->get("text12") should use the path of the data coming from the db
if you want to strip tags after db read and before save then you need to do it twice, the code I posted is to strip tags after read.
then you can strip before save again
if you want to strip tags after db read and before save then you need to do it twice, the code I posted is to strip tags after read.
then you can strip before save again
of course you must use {var:var_name} syntax
You need to login to be able to post a reply.