Support

Account

Home Forums General Issues Naming convention in blocks

Solved

Naming convention in blocks

  • Hey guys

    I was wondering – I know that all fields in options in custom post types and templates should be unique, as to avoid complications. But is it the same for blocks?

    Let’s imagine we have two blocks ‘block_1’ and ‘block_2’ and they are inserted into the same post. Is it okay if both blocks would have field named ‘image’ or could there be conflicts?

    Right now I am always using for blocks fields like ‘b_blockname_image’, but maybe it is redundant and I can use short ones instead of this?

    Thanks in advance!

  • I do not know the answer to this. I would guess that since the values are not stored the same what that the field names might not matter as much.

    There is one way to find out. Create 2 fields with the same name in different blocks and see what happens. If you update one and the same value appears in the second one then you cannot do it. On the other hand, if you can update the two fields with different values and they retain the correct values then you can.

  • Thanks for a quick reply!

    I know that on the first look it doesn’t mess with the fields and it looks good. I was just wondering if it can mess deeper and cause any other problems than just bad displaying of the fields.

    Either way, thanks!

  • Like I said, I’m not sure. I believe that the fields are save to a specific block ID on the page. This makes each field unique to that ID. If you’re not seeing issues in the editor then you probably won’t see issues elsewhere.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.