0

I want to make the default name block in Magento 2.3 as read only. This is the block which is used every where. /vendor/magento/module-customer/view/frontend/templates/widget/name.phtml If i override this file and make first name and last name read only, it get affected every where. I want to make the first name, last name fields readonly only at Account Edit information form. https://prnt.sc/oj7taq But the field becomes read only at Account creation form also. https://prnt.sc/oj7tjj.

How can i make the fields read only at only Edit Account information page. Please help.

2
0

You can try following code

$currentFullAction = $block->getRequest()->getFullActionName();
if($currentFullAction == "customer_account_editPost"){
    // you can make your changes here
    // In your case, you can add **readonly** attribute in input tag
}

In your phtml file

Object Manager is not recommended way

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get('\Magento\Framework\App\Request\Http');
$action = $request->getFullActionName();
if($action == 'customer_account_editPost'){
   // your changes
}
?>

Hope it Helps.

2
  • Can u tell me in which file?
    – Nafsss
    Jul 24 '19 at 6:01
  • in your block file
    – Mohit Rane
    Jul 24 '19 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.