How do I replace characters in a field before updating

How do I replace characters in a field before updating

You need to use a "Custom Trigger" of the "Before" kind
divider

I need to strip out any question marks from a field before I insert/update the record.

The information in this specific field is used as a file-name with mod-rewrite to show friendly URLs. Obviously a question-mark will break the URL as PHP uses question-marks as URI parameters.

You need to use a "Custom Trigger" of the "Before" kind

The code will be

$tNG->setColumnValue("art_heading", trim(str_replace('?',' ',$tNG->getColumnValue('art_heading'))));

Remember to use the escape character \ when you want to replace a " with a '

e.g. $tNG->setColumnValue("art_heading", trim(str_replace('"','\'',$tNG->getColumnValue('art_heading'))));
Written by:  - 11 Sep, 2009