Read data from submitted forms and display it to the user that submitted the form #334
-
Hello community! So if it is something like a support request form, that they can see all their submitted issues and the progress associated with them. Best regards |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
So I Kind of found a workaround. |
Beta Was this translation helpful? Give feedback.
-
Okay, now the way I solve this is NOT the pretty way of doing things, but this is just a POC and would need to carried over to Symfony. I went ahead and added Then to retrieve all data on my frontend, I wrote up this pretty hacky piece of jQuery: $(document).ready(function(){
$.get( "/admin/api/form/dynamics", {
"page": 1,
"locale": "en",
"form": 2,
"sortBy": "created",
"sortOrder": "desc",
"limit": 10,
"fields": ["id","text","radioButtons","textarea","attachment","text1","text2","created"],
"flat": true
},
function( data ) {
var ResponseData = data["_embedded"].dynamic_forms;
ResponseData.forEach(
function(element){
var markup = "<tr><td>" + element.text + "</td>" + "<td>" + element.radioButtons + "</td>" + "<td>" + element.textarea + "</td>" + "<td>" + element.created + "</tr></td>";
if (element.text1 == '{{ app.user.getUsername() }}'){
$('#Reports tbody').append(markup);
}
}
);
});
}); Again, JUST A POC, I know this is very insecure and very very bad practice, SO PLEASE DO NOT CARRY THIS OVER TO YOUR OWN PROJECT! This allows me to retrieve the data submitted to the forms away from the I am sadly not proficient enough with OOPHP and Symfony to pull it off cleanly. Hope someone finds this atleast a little helpful. Best regards |
Beta Was this translation helpful? Give feedback.
-
The sulu form bundle makes a redirect after the form is submitted. This is done to avoid duplicated form submits if a user does a page refresh. That make all data which is submitted to be lost on the target Still it is possible that you listen the the FormSavePostEvent. Then write this data into the session of the user or even better into the flashbag of the session: https://symfony.com/doc/current/components/http_foundation/sessions.html You create a new controller which read that data from the current user session / flashbag and return it as a By reading it over via JS over ajax you make sure that also the You should not expose any admin api to the public as that will leak private information of other users. |
Beta Was this translation helpful? Give feedback.
The sulu form bundle makes a redirect after the form is submitted. This is done to avoid duplicated form submits if a user does a page refresh. That make all data which is submitted to be lost on the target
?send=true
.Still it is possible that you listen the the FormSavePostEvent. Then write this data into the session of the user or even better into the flashbag of the session: https://symfony.com/doc/current/components/http_foundation/sessions.html
You create a new controller which read that data from the current user session / flashbag and return it as a
JSON
. If you are on the?send=true
page your JS need to request that new endpoint you created it and show so the submitted data.By r…