Forums

CF8 - Remove HTML Tags from Text Fields

rbock 01 Oct, 2023
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?
Max_admin 02 Oct, 2023
Answer
Use a PHP action, and set the updated value in a var then use that var in the field Value setting:

In PHP:
$this->set("stripped", strip_tags($this->get("value")));


and in field Value:
{var:stripped}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rbock 11 Oct, 2023
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}
rbock 11 Oct, 2023
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.
Max_admin 11 Oct, 2023
$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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rbock 11 Oct, 2023
And Fieldname for textarea: var:stripped_text12 ?! without [ or { ?!
Max_admin 11 Oct, 2023
of course you must use {var:var_name} syntax
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.