Pimcore 5: Access block editables in areabrick controller

745 Views Asked by At

I know that I can get the value of an editable in the brick controller with:

$this->getDocumentTag($info->getDocument(), $type, $inputName);

But this does not work for block editables.

This:

$this->getDocumentTag($info->getDocument(), 'block', 'example');

...does return the block element, but I do not know how I can access the values of the inputs, checkboxes, etc. inside this block.

1

There are 1 best solutions below

0
On

if you have the block element, then you can so something like this:

foreach($objBlock->getElements() AS $objBlockItem) {

  dump($objBlockItem->getElement('heading')); # will be Pimcore\Model\Document\Tag\Input in my case

}

For reference the block definition:

{% for i in pimcore_iterate_block(pimcore_block('blockname')) %}
  <p>{{ pimcore_input('heading') }}</p>
{% endfor %}

I am doing it in a controller and not in a brick, but should work the same way.