Composer View and Multiple Blocks of the Same Type

Permalink
Experiencing a new issue here, and confirmed it even in the core image slider block.
When adding more than one image slider block to a composer view, composer only loads one of them, but executes things like "Add Slide" twice (if there has been 2 image sliders added to composer view).

In my own custom block I'm building, I have dynamic items as does the image slider. I can atleast get multiple blocks of mine to display separately in composer view, and have the actions only execute on the block being edited, but a strange thing happens when saving composer view. All the entries from both blocks get added into one, and the second block appears empty.

So when saving composer view, composer view takes all the entires from all blocks of the same type, and saves them as one block. All the entries get appended to the first block, and the second appears empty.

How to cause the save function in my controller to separate the posted data from the other block of the same type?

Also, validation does not work in composer view....
public function validate($data)
    {
        $e = Core::make("helper/validation/error");
        $count = count($data['sortOrder']);
        $i = 0;
        while ($i < $count) { // make sure none of the added items are completely blank
            $item = $i + 1;
            if(!$data['title'][$i] > 0 && !$data['fID'][$i] > 0 && !$data['content'][$i] > 0) {
                $e->add(t('You must add something to item ').$item);
            }
            ++$i;
        }
        return $e;
    }

Its like composer doesn't recognize $data post....

I am using $view->field to set the names on the fields. But a curious thing is happening, composer is setting the ptComposer # to the same on each block:
Example, in my first occurrence of my custom block in composer view, the name fields get rendered as:
ptComposer[7][title][]

But in the second occurrence of my custom block in composer view, the name field is the same (ptcomposer[7])
When I look at another block in composer view (not my custom one) it says ptCoposer[9]....
Shouldn't the second occurrence of my block therefore be prefaced with ptComposer[8] instead of also being numbered 7???

ob7dev
 
ob7dev replied on at Permalink Reply
ob7dev
Update:

I find that this has something to do with the fact my block generates input fields whenever a new item is added to the block. And it is here where composer fails to identify it as being separate. If I predefine a input field for example, composer view separates it....
ob7dev replied on at Permalink Best Answer Reply
ob7dev
Fixed:
This issue had to do with using an underscore template to dynamically create inputs, as does the image slider (which needs to be fixed).
I got my block working correctly with composer view by changing the underscore.js ID to being unique.
<script type="text/template" id="repeatableItemTemplate">

to
<script type="text/template" id="repeatableItemTemplate<?php echo $bID?>">