Array expecting string error when fieldtype is used within matrix Im getting an expecting string given array error on a variable in my fieldtype. When output / dumped to the template it is a string. This only happens when used within matrix field.

The trim function here is the specific line throwing the error:

$settings['colours'] = explode(',', str_replace(' ', '', trim($settings['colours'])));


getInputHtml() &amp; prepValue()

public function prepValue($value)
{
    $colour = new FruitStyle_PaletteModel();

    if(is_array($value))
    {
        $colour-&gt;hex = $value['hex'];
        $colour-&gt;opacity = $value['opacity'];
    }

    return $colour;
}

public function getInputHtml($name, $value)
{
    craft()-&gt;templates-&gt;includeJsResource('fruitstyle/js/FruitPalette.js');
    craft()-&gt;templates-&gt;includeCssResource('fruitstyle/css/palette.css');
    craft()-&gt;templates-&gt;includeCssResource('fruitstyle/fonts/fruiticons/style.css');

    $id = craft()-&gt;templates-&gt;formatInputId($name);
    craft()-&gt;templates-&gt;includeJs('new FruitPalette("'.craft()-&gt;templates-&gt;namespaceInputId($id).'");');

    // String or JSON
    $settings = $this-&gt;getSettings();
    if(filter_var($settings['colours'], FILTER_VALIDATE_URL))
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, $settings['colours']);
        $colours = curl_exec($ch);
        curl_close($ch);
        $settings['colours'] = JsonHelper::decode($colours, true);
    }
    else
    {
        $settings['colours'] = explode(',', str_replace(' ', '', trim($settings['colours'])));
    }

    return craft()-&gt;templates-&gt;render('fruitstyle/_fieldtype/palette/input', array(
        'id' =&gt; $id,
        'name' =&gt; $name,
        'value' =&gt; $value,
        'settings' =&gt; $settings,
        'specialOptions' =&gt; $this-&gt;_getSpecialOptions(),
    ));
}
It appears as though $settings['colours'] is an array... which you're then trying to trim and explode.

Can you var_dump($settings['colours'])?

p.s. Nice to see "colours" spelt "correctly" :)