How to create a password or an encrypted field in Magento 2 System Configuration
When you want to create a new field for input any password in system configuration Magento 2 but you don't want it to show the password as a text.
Here we will guide you on how to create a password type field in the admin configuration in Magento 2.
We use the “obscure” field type and
Magento\Config\Model\Config\Backend\Encrypted as the backend_model
In the file <Module_Name>/etc/system.xml add a new field as below:
<field id='magenest_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>
After create in System configuration will show this field for input password as image:
You can see that in configuration at the admin panel with the name Password. When you put or type some value then it will convert the value into a password with dot sign.
In short, when creating a field in the back-end, developers need to create an encrypted field for it for security purpose.
READ MORE. How to encrypt and decrypt data in Magento 2 - Magenest Blog
Happy coding!
-
How to add products to cart programmatically
December 14 2023 -
10 Best Mega Menu Examples in 2024
December 21 2023 -
Customer Value and Satisfaction: What's the Difference?
October 30 2020 -
How to add Custom CSS File in Magento 2
March 14 2020
-
11 Best Magento 2 Social Login Extensions Free and Paid 2024
January 27 2024 -
Payment Gateway Comparison - Top 5 Providers in 2024
January 21 2024 -
6+ Voice Search Statistics and Trends You Can't Miss in 2024
January 20 2024 -
2024 Hottest Trend: Voice Search Technology
January 16 2024 -
Salesforce - No.1 CRM Platform for Magento In 2024
January 14 2024