How To

Magento 2: How to Create a Password or an Encrypted Field in System Configuration

Hello Magento Friends,

Today I am here with a new Magento 2 solution. Today it’s about How to Create a Password or an Encrypted Field in Magento 2 System Configuration.

You might need to add a password field in the system configuration where the input type is abstruse, meaning the data is not shown as text. To create a password type field in the system configuration, perform the below step.  

Steps to Create a Password or an Encrypted Field in Magento 2 System Configuration:

Step 1: First, create a system.xml file at the below path

app\code\Vendor\Extension\etc\adminhtml

We use the “obscure” field type and Magento\Config\Model\Config\Backend\Encrypted as the backend_model.

In the file app/code/Vendor/Extension/etc/adminhtml/system.xml add a new field as below:

<field id='encrypted_password' translate='label' type='obscure' sortOrder='3' showInDefault='1' showInWebsite='1' showInStore='1'>
 <label>Password</label>   
 <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>

Now, you can find that the password field is added to the admin system configuration with encrypted input. When you input any data, it will be shown as dots.

Conclusion:

This way, you can add a password-like field or an encrypted field in Magento 2 system configuration.

Moreover, you can create the following fields in the Magento 2 system configuration:

Also, perform the following actions on Magento 2 system configuration field:

Share this tutorial with your friends and stay updated for more!

Happy Coding!

Click to rate this post!
[Total: 1 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

Recent Posts

Improving Error Handling and Transition Management in Remix with useRouteError and useViewTransitionState

In modern web development, seamless navigation and state management are crucial for delivering a smooth…

6 days ago

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

1 week ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

1 week ago

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

2 weeks ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

2 weeks ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

2 weeks ago