Need to transfer field values from a matrix into a supertable #13430
-
We've got a complex matrix set up for our components, and early on we'd add fields to each component, but then started using supertables to contain them. I'd love to be able to move values into their supertables easily so authors don't have to. Here's an example with all the unnecessary stuff hidden Matrix Field called
Since a component's background color might be set to |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
This can be accomplished using the resave/matrix-blocks command: php craft resave/matrix-blocks \
--field mainComponents \
--type "hero" \
--set sectionConfig \
--to "fn(\$block) => ['new1' => ['type' => 1, 'fields' => ['backgroundColor' => \$block->backgroundColor, 'externalSpacing' => \$block->externalSpacing]]]" Update <input type="hidden" name="fields[mainComponents][blocks][2149][fields][sectionConfig][blocks][2162][type]" value="1"> Repeat the command for each Matrix block type, replacing |
Beta Was this translation helpful? Give feedback.
-
This is working great for us! One question: what is the |
Beta Was this translation helpful? Give feedback.
-
After a few rounds of wondering why this wasn't working, I re-read all your instructions. So I'll put them here in case someone else needs the help. |
Beta Was this translation helpful? Give feedback.
This can be accomplished using the resave/matrix-blocks command:
Update
'type' => 1
with the actual Super Table block type ID. You can find it via a hidden input at the beginning of an input’s table row, within an entry edit page:Repeat the command for each Matrix block type, replacing
hero
with the Matrix block typ…