N
N
nnkrasovok2019-05-21 15:27:00
Yii
nnkrasovok, 2019-05-21 15:27:00

How to make a preview of the entered data from the form?

The user has filled in the form fields. How can I preview this data before sending it to the server?
For example, like on a toaster, there is a possibility to preview the question

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly Kulikov, 2019-05-21
@anatoly_kulikov

The first thing that comes to mind is to write a simple function in JS and hang an event on a button. When activated, the editor block is removed/hidden and a preview is drawn.

E
Eugene, 2019-05-25
@ev_g

What is the form about?
How many fields? Are there pictures to download? Are there complex fields that are not just input, but which contain more complex processing logic?
I would do it with Pjax.
There are two buttons in the form - publish and preview. Each of them changes some hidden field in the form and submits the form to the server. The controller validates the form and, depending on the hidden parameter, either saves the model and redirects to another page, or returns the render.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question