silverstripe-cropperfield icon indicating copy to clipboard operation
silverstripe-cropperfield copied to clipboard

Array to string conversion notice

Open micschk opened this issue 9 years ago • 0 comments

Really nice and much requested functionality! I'm using it on SS3.3.2 but running into "PHP Notice: Array to string conversion in ... /framework/forms/FormField.php".

Looking into this, it seems the $value of the CropperField is:

array(2) {
  ["Enabled"]=>
  string(2) "on"
  ["Data"]=>
  string(38) "{"x":2,"y":2,"width":196,"height":196}"
}

This gets inserted as string at FormField::getAttributesHTML() (l.617):

$parts[] = sprintf('%s="%s"', $name, Convert::raw2att($value));

It would appear to me Convert::raw2att() should be expected to handle array to string conversion in some way (json_encode?), as an html attribute can only be a string as far as I know (method signature says array or string return though). FormField::getAttributesHTML does take care of a boolean to string conversion (e.g. readonly="readonly"), so maybe that's where an array to json conversion should happen as well?

This whole thing is a bit of a stab in the dark, as I'm not sure how CropperField is handling its value internally/in the front-end, hope someone else can shed some light on this?

micschk avatar May 20 '16 04:05 micschk