verbb / tablemaker

A user-definable table field type for Craft CMS
MIT License
40 stars 32 forks source link

[Craft 3] Entry not saving when used inside a Matrix block #9

Closed john-henry closed 6 years ago

john-henry commented 6 years ago

I'm using TableMaker as a block inside Matrix and get the following error when trying to save an entry. Something to do with saving that columns array in the matrix field.

The site was an upgrade from Craft 2 so existing column arrays exist and render perfectly fone on site but it's just the act of saving an entry now throws this error

Craft CMS 3.0.1

Anything else I can provide you with let me know

yii\base\UnknownPropertyException: Setting unknown property: craft\behaviors\ContentBehavior::columns in /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/BaseObject.php:163

Stack trace:

0 /Users/johnhenry/Sites/mysite-local/storage/runtime/compiled_classes/ContentBehavior.php(814): yii\base\BaseObject->__set('columns', Array)

1 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/base/Element.php(1590): craft\behaviors\ContentBehavior->__set('columns', Array)

2 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/base/Element.php(1569): craft\base\Element->setFieldValue('columns', Array)

3 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/fields/Matrix.php(870): craft\base\Element->setFieldValues(Array)

4 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/fields/Matrix.php(362): craft\fields\Matrix->_createBlocksFromSerializedData(Array, Object(craft\elements\Entry))

5 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/base/Element.php(1903): craft\fields\Matrix->normalizeValue(Array, Object(craft\elements\Entry))

6 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/base/Element.php(761): craft\base\Element->normalizeFieldValue('pageComplex')

7 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\base\Element->__get('pageComplex')

8 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/web/View.php(466): yii\base\Model->toArray(Array, Array, false)

9 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/helpers/ElementHelper.php(149): craft\web\View->renderObjectTemplate('{% if object.le...', Object(craft\elements\Entry))

10 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/helpers/ElementHelper.php(92): craft\helpers\ElementHelper::_renderUriFormat('{% if object.le...', Object(craft\elements\Entry))

11 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/validators/ElementUriValidator.php(49): craft\helpers\ElementHelper::setUniqueUri(Object(craft\elements\Entry))

12 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/validators/Validator.php(267): craft\validators\ElementUriValidator->validateAttribute(Object(craft\elements\Entry), 'uri')

13 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(craft\elements\Entry), Array)

14 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/services/Elements.php(377): yii\base\Model->validate()

15 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/controllers/EntriesController.php(539): craft\services\Elements->saveElement(Object(craft\elements\Entry))

16 [internal function]: craft\controllers\EntriesController->actionSaveEntry()

17 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

18 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

19 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/web/Controller.php(74): yii\base\Controller->runAction('save-entry', Array)

20 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-entry', Array)

21 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/web/Application.php(238): yii\base\Module->runAction('entries/save-en...', Array)

22 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/web/Application.php(446): craft\web\Application->runAction('entries/save-en...', Array)

23 /Users/johnhenry/Sites/mysite-local/vendor/craftcms/cms/src/web/Application.php(222): craft\web\Application->_processActionRequest(Object(craft\web\Request))

24 /Users/johnhenry/Sites/mysite-local/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))

25 /Users/johnhenry/Sites/mysite-local/web/index.php(21): yii\base\Application->run()

26 {main}

Nav33d commented 6 years ago

Hi John,

Yes, I can replicate this issue. I'm looking into it and will update you once I have fixed this.

Many thanks

john-henry commented 6 years ago

Just so ya know, its happening on Craft 3.0.2. Realise nothing to do with error but from the point of being thorough.

john-henry commented 6 years ago

Ok so here is a clue. If I manually add

public $columns;
public $rows;

to _storage/runtime/compiledclasses/ContentBehaviour.php it works

Related issue

Nav33d commented 6 years ago

Hi @john-henry

I have just released version 2.0.0 which fixes the Matrix issue.

Could you please update the TableMaker plugin. Just to be on safe side take backup of the existing data in case something goes wrong.

Many thanks

ijy commented 6 years ago

Fantastic timing. I literally just came to check if there was a Craft 3 version out yet. :D Thanks

john-henry commented 6 years ago

Update works great too so far. Thanks for your time.