What is data persistor

Blog
Spread the love

In this blog, we’ll learn what is data persistor and how to use it. When we fill out a form and something goes wrong in it, then the whole form is reloaded and the data gets erased. It’s very difficult to enter all data one by one. Data persistor will solve this problem. It’s just a class that stores data on the current user session. You can set, get, and clear data from the session.

Step 1- Add layout file with argument( form_index_index.xml)

Create layout file in app/codeBluethink/Customform/view/frontend/layout.

In your layout file, you need to add argument as shown below:

Step2 – Now we need to get data of user.

We need entered data of user to display on text field.

Create UserDataProvider.php in app/code/Bluethink/Customform/ViewModel folder.

Now we have customer data 🙂

Step 3- We create function required by ViewModel UserDataProvider

Create helper file Data.php in app/code/Bluethink/Customform/Helper folder.

Step 4- Let’s Call ViewModel on the Form

Create save.php in Controller/Index folder.

Step 5 – We need to call data persistor on the controller

Please comment is you have any query

bluethinkinc_blog

bluethinkinc_blog

2022-12-22

1

One Reply to “What is data persistor”

  • Avatar
    Shubham Singh

    Nice blog

    2022-12-22 at 10:27 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

How to Add a Custom Tab to the Customer Order Detail Page in Magento 2

Spread the love Adding a custom tab to the Order Detail

Exception Handling in Java

Spread the love Introduction – Exception:An unwanted

How to add custom less file in Magento2

Spread the love Source files *.css included into layout

Spring Boot Microservices

Spread the love Microservices architecture has become

Implementation of WireMock for better testing

Spread the love WireMock is a flexible and powerful tool

Magento 2: How to selected default option in configurable options?

Spread the love Configurable products in Magento 2 allow

How To Implement Simple JWT Authentication in Django Rest Framework

Spread the love We’ll learn how to use simple JWT

Optimizing Search: Integrating Elasticsearch in Django Applications

Spread the love What is Elasticsearch? Elasticsearch is a

How to create Customer Segments

Spread the love In Magento 2, “customer

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

bluethinkinc Blogs