Closed rob-baker-ar closed 3 years ago
Are you able to send through a screenshot of your blocks, or field setup? I can't seem to replicate this behaviour. See https://d.pr/v/cVQgFx
In that album, the first 3 screens show what happens.
The last 2 show the field config for the Matrix block in question. Fields are 3 Drop downs and a 1 lightswitch.
I should add that if I try to clone or duplicate a Matrix block (from another field) containing only a Redactor field it duplicates fine.
[Edit: It looks like imgur messed with the order of the images, - the above still applies but not necessarily in that order!]
Thanks for the image, I still can't replicate it which is frustrating.
I've just added some more logging in 1.1.9 if you feel like giving that a spin. There must be something unique with that field or blocktypes...
Hi @engram-design , I updated to 1.1.9 and ran through the above again.
Got the following in ./storage/logs/smith.log
...
2020-10-20 08:51:45 [-][1][-][error][smith] Unable to find Block Type for “tileStart” for field “219”.
2020-10-20 08:51:45 [-][1][-][error][smith] {"tile":{"id":"33","fieldId":"219","fieldLayoutId":"54","name":"Tile","handle":"tile","sortOrder":"1","hasFieldErrors":false,"uid":"f03ee682-4d5b-4409-945c-39a346ecaf14"}}
The POST data was:
$_POST = [
'field' => 'tiles'
'namespace' => ''
'blocks' => [
0 => [
'type' => 'tileStart'
'enabled' => '1'
'fields' => [
'context' => 'is-parent'
'direction' => 'is-vertical'
'columnWidth' => ''
'active' => '1'
]
]
]
'placeholderKey' => '••••••••••'
]
Around line 49 in FieldController $blockTypes
has a key of 'tile' (which is the Matrix block type handle) but it seems $blockData['type']
is 'tileStart' (which is the handle for the field within the Matrix). $blockType = $blockTypes[$blockData['type']] ?? null;
resolves to null and the error is logged.
Great, so that's a good start.
So as the error states, it can't find the blocktype you're trying to copy in field ID 219. Can you confirm a blocktype with the handle of title
exists in this field? Just trying to figure out which is the correct handle - tileStart
or tile
.
OK, after some digging:
There are 2 different Matrix fields with the handle tiles
with different contexts and different block types.
One is this one, exhibiting the issue (with block types: tileStart
, contentBlock
and tileEnd
and a fieldId of 238).
The other exists in another field group used on a different section (has a single block type tile
and a fieldId of 219).
Smith seems to be getting the wrong Matrix block type data. In the same controller as above, line 41 it gets the first field with a matching handle then later gets the block types out of it. In my case, I have 2 Matrix fields with the same handle.
I'm not even sure that's a valid situation to be in, in which case there may be a Craft bug at the route of this that allowed 2 Matrix fields with the same handle to be created (although they are only used in different contexts so perhaps it is ok).
You mention I have 2 Matrix fields with the same handle
that shouldn't be possible right? If they have different contexts, they must be being used in Super Table or Neo fields?
I can investigate further knowing that much though
I didn't think it was possible. You are right - field id 219 is set as a child of a Super Table field, the field being found by the code $field = ArrayHelper::firstWhere(Craft::$app->fields->getAllFields(false), 'handle', $fieldHandle, true);
on line 41 of the controller... But field id 238 is the correct field.
Field 219 has a context column of superTableBlockType:eea54c8e-1952-45a6-acbc-8f5b64dee01d
.
Field 238 (the matrix that sparked this issue) has a context of global
.
This is according to the fields
databases table.
Think I've figured this out, if you're able to try by changing your verbb/smith
requirement in composer.json
to:
"require": {
"verbb/smith": "dev-craft-3 as 1.1.9",
"...": "..."
}
Then run composer update
.
Done - works great now - many thanks.
Great, thanks for your persistence on this. Fixed in 1.1.10
No problem - it's going to help a few of our content editors on a couple of sites, so thank you for your work on the plugin.
Steps to reproduce
Additional info
Additional context
The POST request to
https://hostname/index.php?p=[...]/actions/smith/field/render-matrix-blocks
looks like this:And the response like this:
Cannot see any logged errors.