Forum

Thread tagged as: Problem, Error

Blocks: Using related field type inside a block

Hello,

Another bug with blocks - using a perch:related field type inside a block the "Selectize" UI doesn't initialise so we're presented with a simple html multi-select. Would be goo to have this fully operational inside blocks!

Thanks

Oliver Lowe

Oliver Lowe 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, interesting. What's the scenario where it would make sense to create a relationship inside a block.

I'm building a "content builder" style default page for an editor to add content to. Sometimes it's useful for an editor to add a related event or course to a page, sometimes multiple events and courses. Along with normal text/heading blocks, and figures (images, videos etc). I don't want all the selected events to appear in one big list, but give them flexability to add one related event (perhaps related to the paragraph they just wrote), then add another text block, or image, then perhaps add a related course, and to allow them to reorder the blocks. I'm currently setting a limit of 1 on the related tag to force the editor to create a new block when they want to add another related item.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, ok, that makes sense. Thank you. I'll take a look at it and see what I can do.

The template code I'm using is basically this with a some extra html, in case it's useful:

<perch:block type="event" label="Related Event" icon="calendar">
    <perch:related id="event" collection="Events" label="Event" max="1" count="1">
    ...
    </perch:related>
</perch:block>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Thanks.