Closed tjdraper closed 4 years ago
Thanks for the report. That's interesting, are you using the latest version (1.2)? I didn't anticipate the entry type dropdown. That said, it technically should be working as the plugin listens for when matrix fields get init'ed.
Let me check it out and see if I can replicate
Odd. I'm so sorry, I thought I was running the latest version before the bug report because the latest tagged version is not showing up in Craft. But I'm running 1.1.3.
I'll try 1.2 and let you know.
I'm going to try to point composer at this repo manually to pick up and test 1.2.0, but I thought you'd want to know that Packagist is not picking up 1.2.0.
Ah, that's weird. I think I had an issue with the composer version number. I've just added a new 1.2.1
release that looks like it's appearing correctly:
https://packagist.org/packages/weareferal/matrix-field-preview#1.2.1
Now getting this when updating to 1.2.1.
Database Exception: SQLSTATE[HY000]: General error: 1553 Cannot drop index 'craft_matrixfieldpreview_blocktypes_config_siteId_fk': needed in a foreign key constraint
The SQL being executed was: ALTER TABLE craft_matrixfieldpreview_blocktypes_config DROP COLUMN siteId
Migration: weareferal\matrixfieldpreview\migrations\m201031_132510_remove_unused_site_id
Output:
> drop column siteId from table {{%matrixfieldpreview_blocktypes_config}} ...Exception: SQLSTATE[HY000]: General error: 1553 Cannot drop index 'craft_matrixfieldpreview_blocktypes_config_siteId_fk': needed in a foreign key constraint
The SQL being executed was: ALTER TABLE craft_matrixfieldpreview_blocktypes_config DROP COLUMN siteId (/var/www/vendor/yiisoft/yii2/db/Schema.php:677)
#0 /var/www/vendor/yiisoft/yii2/db/Command.php(1298): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE cr...')
#1 /var/www/vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('ALTER TABLE cr...')
#2 /var/www/vendor/yiisoft/yii2/db/Migration.php(392): yii\db\Command->execute()
#3 /var/www/vendor/weareferal/matrix-field-preview/src/migrations/m201031_132510_remove_unused_site_id.php(20): yii\db\Migration->dropColumn('{{%matrixfieldp...', 'siteId')
#4 /var/www/vendor/craftcms/cms/src/db/Migration.php(52): weareferal\matrixfieldpreview\migrations\m201031_132510_remove_unused_site_id->safeUp()
#5 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#6 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(weareferal\matrixfieldpreview\migrations\m201031_132510_remove_unused_site_id))
#7 /var/www/vendor/craftcms/cms/src/services/Updates.php(257): craft\db\MigrationManager->up()
#8 /var/www/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(509): craft\services\Updates->runMigrations(Array)
#9 /var/www/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#11 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /var/www/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#13 /var/www/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('migrate', Array)
#14 /var/www/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#15 /var/www/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('updater/migrate', Array)
#16 /var/www/vendor/craftcms/cms/src/web/Application.php(665): craft\web\Application->runAction('updater/migrate')
#17 /var/www/vendor/craftcms/cms/src/web/Application.php(232): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#18 /var/www/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /var/www/web/index.php(13): yii\base\Application->run()
#20 {main}
Damn, looks like an issue with the migrations I've added. I'll have to debug locally and get back to you.
@tjdraper OK I was able to replicate this and I've hopefully got a fix for it in the latest release. Please download version 1.2.3 and try the migration again. Apologies, I know these migration issues are annoying.
Thanks! 1.2.3 resolves the migration issue. AND it looks like this version does resolve the original issue.
Great, glad both issues are sorted 👍
When viewing an entry or creating a new entry, when selecting a different entry type with the entry type switcher, Matrix Field Preview does not initialize on the Matrix fields (existing from the previous entry type or new fields) in the entry type.
Before switching entry types:
After switching entry types: