render out Tag multi-select block.

Permalink
I am trying to render out the same input field used for adding tags attribute to a page in composer edit mode.

When I attempted to render out the field in a for each loop, the correct values don't display and instead the values from the first page in the loop displays in all the following ones.

code
<?php
$pages = $pagination->getCurrentPageResults();
foreach ($pages as $cobj) {
echo $cobj->getAttributeValueObject('tags');
$ak = CollectionAttributeKey::getByHandle('tags');
$av = $cobj->getAttributeValueObject('tags');
$ak->render('form', $av);
}
?>
/code

Trying to have the same functionality as the Tags input field used in the concrete5 block.