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;

  • Can you post the relevant code? Also the save() function looks for an array, not a string...
    – jrothafer
    Commented Aug 10, 2015 at 14:13
  • I've added the save function above. :-)
    – Diederik
    Commented Aug 10, 2015 at 14:35

1 Answer 1


The problem is resolved.

The fieldtype was using array data. But I rewrote it to save the data as a simple string. Makes things easier if you want it to work with some add-ons like Publisher.

But I forgot to remove var $has_array_data = TRUE; from the class. Simply removing it, or setting it to FALSE solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.