Adding shadow block to dynamic input fields

300 views
Skip to first unread message

Psycho Buddha

unread,
Sep 13, 2022, 1:31:00 PM9/13/22
to Blockly
Hello all,

I am trying to add shadow block to all of my blocks and I was able to do it on a 'regular' blocks, I got bit stuck on the ones where the inputs fields are generated dynamically based on the selected drop-down value.

I wasn't able to get much help from the documentation, since it seems that shadow blocks are defined and used via XML. I was also reading Beka's blog where she gives some examples in XML. However, I am using JavaScript for the definition of the blocks and that might be one of the reasons I got stuck.

The error message I am getting is:
message: "The block \"pti\" block (id=\"ENr:ZBz!QNl6Wk*K~B::\") is missing a(n) value\nconnection"
As I could see it is related with serialization and the docs say that we should use either XML or JSON for it.

In the block mentioned above, I am using a validator and updateConnections() method for adding/removing inputs.

Did anyone had similar example in their work? Is it worth struggling with it, or you would recommend different approach? As an alternative, I am going to try to use default values instead of shadow blocks, but still searching for some examples.

Thank you!

Aaron Dodson

unread,
Sep 13, 2022, 4:51:24 PM9/13/22
to Blockly
Hi,

This sounds sort of similar to https://groups.google.com/g/blockly/c/Cwe6TGH8vuA - does the solution described there work for your case?

- Aaron

Psycho Buddha

unread,
Sep 14, 2022, 7:23:27 AM9/14/22
to Blockly
Hi Aaron,

I am gonna need some time to experiment, but this looks close to what I have been looking for, thank you very much!

-Buddha
Reply all
Reply to author
Forward
0 new messages