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

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

Google Ads Conversion Tracking Through Magento Platform:

Spread the love Google Ads Conversion Tracking Through

Object Pool Pattern in Magento2

Spread the love What is Object Pool Pattern in Magento 2 An

JENKINS

Spread the love JENKINS Introduction and Installation

Virtual Type and Type

Spread the love Virtual type is one of the most common

Customize the length of Input field

Spread the love Sometimes we need to change the limit the

How to Add Custom Tab on Admin Dashboard and Count Website Total Visitor in Magento 2?

Spread the love In this blog we’ll see How to Add Custom

How to Add Sign Out Tab in Customer Account in Magento 2?

Spread the love In this blog we’ll see How to Add

How to create custom tab in product detail page in magento 2?

Spread the love In this blog we’ll see how to add

Understanding and Implementing CORS & CSRF

Spread the love What is security? The world has become more

bluethinkinc Blogs