I'm creating a custom field type. But the data isn't being saved to the database. There are several values that are being combined into a string, divided by a pipe character.
I've checked the save()
function, and it returns the string that I want to have saved in the database. But when I check the database, the field is empty, or has only one character.
Example string: http://s3-eu-west-1.amazonaws.com/xyz/xyz/filename.jpg|55|170|541|541|1:1|260|260
But actually, it doesn't matter what string it is. It never gets saved. Or in some cases only the first letter.
What could I be doing wrong?
EDIT: the save function itself
function save($data)
{
$content = FALSE;
$custom = array();
foreach($this->custom_fields as $key)
{
$val = ee()->input->post($key.'_field_id_'.$this->field_id);
$custom[] = $val;
if (strlen($val)>0)
{
$content = TRUE;
}
}
$toReturn = "";
if ($content)
{
$toReturn = utf8_encode(implode('|', $custom));
}
return $toReturn;
}