i search around a lot about references of this function. but the documentation have a big lack. does somebody explain me this part of code (deeply) ?
$this->getLayout()->createBlock(
ClassElementLikeSelect::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
i don't understand this solution. i find this everywhere but nobody explain why you set that argument (is_render_to_js_template for example) .
UPDATE:
the createBlock is definite with block Factory and are inside these classes
1 Answer 1
This is only used in a couple of places
/**
* Block Factory
*
* @param string $type
* @param string $name
* @param array $arguments
* @return \Magento\Framework\View\Element\AbstractBlock
*/
public function createBlock($type, $name = '', array $arguments = [])
So it's arguments that you are passing to block.
As to why. I'm baffled. Other than online tutorials and the two references above I can't find anything.
You can echo out blocks. Sometimes useful for debugging. See if it makes a difference to output?
echo $this->getLayout()
->createBlock('Vendor\Extension\Block\Hello')
->toHtml();
-
thank you man probably i have found the answer i put under the question. but you help me a lot really thanksPavel– Pavel2019年06月14日 06:42:23 +00:00Commented Jun 14, 2019 at 6:42