Can we write a <block> in out layout file without any "type" parameter?

Can we write a block tag in our layout without its type parameter, such as below

<block  name="formInput" template="Pfay/UserForm/FormInput.phtml" />

what is the other way to do this if i don't have any block associated to my template file ?

Solutions

as you want to use a template, you have to use a type, which supports templates. The most generic type you can use for this is core/template

As already said, you have to use a type, because there is no default type. On the other side there are a lot of blocks, which dont even support templates.

type attribute is mandatory. Or you can use class attribute instead of type, but both of same thing:

<block class="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
  ...
</block>

or

<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
      ...
</block>

See this line (/app/code/core/Mage/Core/Model/Layout.php):

protected function _generateBlock($node, $parent)
{
        if (!empty($node['class'])) {
            $className = (string)$node['class'];
        } else {
            $className = (string)$node['type'];
        }
        //....
}
Tags: Magento 1.x

Similar questions

Incompatible argument type: Required type: string. Actual type: \Magento\Store\Model\StoreManagerInterface;
I have setup a website on local. Magento version is 2.2.4 and php version is 7.0.33 Frontend is working but admin is not working after upgrade and deploy the code. But getting error during compilation: File code
Out of stock images - Grey out if products are out of stock in Magento 2
I see that there is a solution for M1. Would this work for M2? https://stackoverflow.com/questions/35292353/out-of-stock-images-grey-out-if-products-are-out-of-stock-in-magento-1-9-x
Is there any easiest way to make changes CSS & JS, and show changes without setup:static-content:deploy & without disabling static content generation?
Can anyone suggest the easiest way to make changes CSS & JS without setup:static-content:deploy every time. And without disabling static content generation.
Custom module's block doesn't show up - xml layout file 'type' issue?
Block created inside custom module doesn't show up in the fron-end. Namespace: Fmat Module: FtPrices Custom Block file: Fmat/FtPrices/Block/Product/View/Tierprices.php custom block php file: block's definition in module's config.xml (...etc/config.xml) in module's layout file: in catalog/product/view.phtml I get the block via: Once I change block t...
Call a block in layout.xml file with A/B type
This is about block type which I don't know exactly. What is "A/B" as block type there? Any help appreciated.
Magento: How to write an extension with a block that overrides functionality and another new custom block?
I was in the middle of writing some code for a Magento website, and I feel like I'm at odds with what I am trying to accomplish. I am trying to write an extension which inserts 2 blocks: Hello_Catalog_Block_Category_View: which overrides the Mage_Catalog_Block_Category_View Block with some extra functionality. Hello_Catalog_Block_Custom: which is a...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.