CF8 - Remove HTML Tags from Text Fields

Remove HTML tags from text fields in ChronoForms.

Overview

The issue occurs when loading data from or saving data to the database with unwanted HTML tags present.
Use a PHP action to strip tags, setting the cleaned value in a variable. Then, reference that variable in the field's Value setting using the correct syntax. Apply this process both after loading from the database and before saving to it.

Answered
ChronoForms v8
rb 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 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.
rb 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}
rb 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 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.
rb rbock 11 Oct, 2023
And Fieldname for textarea: var:stripped_text12 ?! without [ or { ?!
Max_admin 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.
This topic is locked and no more replies can be posted.