We can override form/login.phtml file by just copy login.phtml file to our theme level easily without any code customization. login.phtml file contains the code of login form of site,They contain email and password field.
For custom module requirement, we need to overwrite login.phtml file in module level so we need to create customer_account_login.xml file.
Create XML file at app/code/Rbj/Customer/view/frontend/layout/customer_account_login.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="customer_form_login"> <action method="setTemplate"> <argument name="template" xsi:type="string">Rbj_Customer::form/login.phtml</argument> </action> </referenceBlock> </body> </page>
Now keep our login.phtml file at app/code/Rbj/Customer/view/frontend/templates/form/login.phtml
Keep content from core login.phtml file to our custom file.
Run command,
php bin/magento cache:clean
Open link, {YOUR_SITE_URL}/customer/account/login
You can get your override file changes.