Just installed Magento CE 1.9.3.1 into my local system.
Then I tried to override the default text input field of Varien class just to add "placeholder" attribute.
etc/config.xml of my module:
<?xml version="1.0"?>
<config>
<modules>
<Custom_PlaceholderAttribute>
<version>1.0.0</version>
</Custom_PlaceholderAttribute>
</modules>
<global>
<blocks>
<placeholderattr>
<rewrite>
<text>Varien_Data_Form_Element_Text</text>
</rewrite>
</placeholderattr>
</blocks>
</global>
</config>
Block class file of module:
<?php
class Custom_PlaceholderAttribute_Block_Adminhtml_Text extends Varien_Data_Form_Element_Text {
public function getHtmlAttributes() {
$attributes = parent::getHtmlAttributes();
$attributes[] = 'placeholder';
return $attributes;
}
}
Now when I try to change fieldset type, in any block-form file, by adding below line, it is giving me Fatal Error
.
$fieldset->addType('text', Mage::getConfig()->getBlockClassName('placeholderattr/adminhtml_text'));
The Fatal error I am getting is:
Fatal error: Class 'Mage_Placeholderattr_Text_Block_Adminhtml_Text' not found in C:\UwAmp\www\testmage1931\lib\Varien\Data\Form\Abstract.php on line 146
But if I try this, rewrite works fine:
$fieldset->addType('text','Custom_PlaceholderAttribute_Block_Adminhtml_Text');
Why block type doesn't work in getBlockClassName()
, can somebody clarify/explain the reason for this ?