I have created a custom module app/code/Demo/Mymodule and I want to override Contact Form Block.
After configuration and registration of module, I have Created di.xml in app/code/Demo/Mymodule/etc
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Contact\Block\ContactForm" type="Demo\Mymodule\Block\ContactForm" />
</config>
Then, I have created ContactForm.php in app/code/Demo/Mymodule/Block
<?php
namespace Demo\Mymodule\Block;
use Magento\Framework\View\Element\Template;
class ContactForm extends \Magento\Contact\Block\ContactForm{
public function getFormAction() {
echo "Demo Text";
return $this->getUrl('contact/index/post', ['_secure' => true]);
}
}
I have run all the commands like:
php bin/magento setup:upgrade
php bin/magento cache:clean
But, I am not getting output (Demo Text) on contact page