Is it possible to get the block name of the current template?
For example I added a block to catalog_product_view.xml:
<block class="Magento\Contact\Block\ContactForm" name="firstname" template="Company_Contact::forms/partials/fields/firstname.phtml"> <arguments> <argument name="required" xsi:type="boolean">0</argument> </arguments> </block> How can I get the name of the block (firstname) inside the template .phtml file?
I tried:
<?php $name = $block->getName(); // Output -> empty Expected: firstname