Pre-save helpers
(Since 1.8.1) -- run code right before a pod item is saved to the database
A Before Helper lets you run code or modify column values RIGHT BEFORE a record is saved to the database. These helpers are especially useful for validation.
How to Assign
When editing a Pod, there is a “Before Helper” drop-down
Usage
- Use $params->datatype for the Pod name
- Use $columns['field_name']['value'] to call the field values
Error Handling
When there's an error, use the following code to stop the form from processing. NOTE: "Error: " is required to be the first thing output on the page to alert the user.
<?php
if($columns['field_name_here']['value']=='Something that it should not be')
{
die('Error: This is not the correct value, please check the Field and try again.');
}
?>
Examples
Here's a Before helper in action!<?php // let's make sure they don't include HTML in their name $columns['name']['value'] = strip_tags($columns['name']['value']); ?>
