presseddigital / colorit

A slick color picker fieldtype plugin for the Craft CMS control panel
Other
21 stars 8 forks source link

Cannot use object of type craft\fields\data\ColorData as array #7

Open richhayler opened 5 years ago

richhayler commented 5 years ago

I have just purchased the plugin and attempting to use a ColorIt field within an asset and encountering an "Internal Server Error" message when navigating any pages on the website.

I have an asset field named "hero" that holds a hero image for just about every page on the site. I've created a ColorIt field named "colour" and added this field to the asset (by using the asset field layout designer within the control panel).

Now I am encountering an Internal Server Error when trying to navigate any page within the website (despite not referencing this field directly in any of the templates, i.e. i'm only referencing the hero asset field itself). I've had to disable the plugin while I troubleshoot this this.

Stack Trace

`Error: Cannot use object of type craft\fields\data\ColorData as array in .../vendor/fruitstudios/colorit/src/helpers/ColorHelper.php:120 Stack trace:

0 .../vendor/fruitstudios/colorit/src/helpers/ColorHelper.php(166): fruitstudios\colorit\helpers\ColorHelper::hexToRgba(Object(craft\fields\data\ColorData), false, false)

1 .../vendor/fruitstudios/colorit/src/services/Colors.php(47): fruitstudios\colorit\helpers\ColorHelper::hexToRgb(Object(craft\fields\data\ColorData), false)

2 .../storage/runtime/compiled_templates/1c/1cb8af7c565cbba5abce0e7ed940ab026478ed2ae56a2870ac33a5558d1c5268.php(70): fruitstudios\colorit\services\Colors->hexToRgb(Object(craft\fields\data\ColorData))

3 .../vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_d3391f693a3ad73328e825b516e13e6f4723c60689f6034b89813fdb8b44daa4->doDisplay(Array, Array)

4 .../vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)

5 .../vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)

6 .../vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)

7 .../storage/runtime/compiled_templates/88/88a378c93f022f68abd6f71c4ba63299e6aff30024b1c9e11e00b1905d025fde.php(128): craft\web\twig\Template->display(Array)

8 .../vendor/twig/twig/lib/Twig/Template.php(189): __TwigTemplate_2450320e3e660b148960b901607e17e977d3be434a63292167ed3afa67adf3b2->block_head(Array, Array)

9 .../storage/runtime/compiled_templates/88/88a378c93f022f68abd6f71c4ba63299e6aff30024b1c9e11e00b1905d025fde.php(36): Twig_Template->displayBlock('head', Array, Array)

10 .../vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_2450320e3e660b148960b901607e17e977d3be434a63292167ed3afa67adf3b2->doDisplay(Array, Array)

11 .../vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)

12 .../vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)

13 .../vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)

14 .../storage/runtime/compiled_templates/bb/bba82f18f9820a5e3cb24e8bada5ab79707d91c54f978d3c44648e77fdff5362.php(49): craft\web\twig\Template->display(Array, Array)

15 .../vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_08aeb9ccde32e4d60a7b1a95913eadb505dac6b7b96f7a46b621a3b5bbb801f2->doDisplay(Array, Array)

16 .../vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)

17 .../vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)

18 .../vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)

19 .../storage/runtime/compiled_templates/3d/3dcfefa8816644ecc1b905b2bed871e03a3e5ec5ef52657b7c9e012dea11cced.php(43): craft\web\twig\Template->display(Array, Array)

20 .../vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_24afafdf52eeeaa928c5d1430cca35e43b7a73c7751e581b0fe26c678934555a->doDisplay(Array, Array)

21 .../vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)

22 .../vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)

23 .../vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)

24 .../vendor/twig/twig/lib/Twig/Template.php(375): craft\web\twig\Template->display(Array)

25 .../vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)

26 .../vendor/craftcms/cms/src/web/View.php(331): Twig_Environment->render('', Array)

27 .../vendor/craftcms/cms/src/web/View.php(378): craft\web\View->renderTemplate('', Array)

28 .../vendor/craftcms/cms/src/web/Controller.php(156): craft\web\View->renderPageTemplate('', Array)

29 .../vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('', Array)

30 [internal function]: craft\controllers\TemplatesController->actionRender('', Array)

31 .../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

32 .../vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

33 .../vendor/craftcms/cms/src/web/Controller.php(104): yii\base\Controller->runAction('render', Array)

34 .../vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)

35 .../vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('templates/rende...', Array)

36 .../vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)

37 .../vendor/craftcms/cms/src/web/Application.php(271): yii\web\Application->handleRequest(Object(craft\web\Request))

38 .../vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))

39 .../public/index.php(21): yii\base\Application->run()

40 {main}`

richhayler commented 5 years ago

Are you able to verify the problem i'm encountering above? Can I help provide any additional details?

samhibberd commented 5 years ago

@richhayler again, unable to recreate, your logs mention a craft\fields\data\ColorData class, this is the Craft Color fieldtype, which is being passed to one of the Colour Helpers, which won't work.

Have you got any template / code for me to review.

Thanks,

Sam

richhayler commented 5 years ago

Thanks for investigating. I’ll setup an example and template on my staging server and will send you the details. :)