Symfony form validation on redirected page - forms

Is it possible to display the form error on a redirected page instead of a rendered page?
I have 2 forms on 1 page each submitting to their own actions. If form 1 is not valid it will skip if($form->isValid()) and go straight to render
which will then display the form errors. The 'render` for this actions only displays form 1).
The issue with this is I would like it to redirect back to the original page where I have both of the forms but still display the form errors.

I don't know any easy way to do this, so I give you an idea how this could be done the "hard" way:
Serialize the validated form using JMSSerializerBundle
Set the serialized form as flashbag message
Redirect
Check for the form in the flashbag, unserialize, show the errors of both.

Related

Laravel 5.4 - Display errors to appended inputs in a form

Whatsup guys
I am struggling with an issue which is displaying errors on appended inputs in a form after submit. I guess there is a simple solution on this which i dont know of because i am a newbie in Laravel.
Scenario:
I have a form where a user needs to select a category and depending on the selection, a few inputs should be appended (with ajax) into the same form below the category dropdown. I have set up the validations and the error rendering on the html but it doesnt seem to work yet the request doesnt pass since it detects the validations.
Any clues?
You will not be able to display the errors next to form inputs that have been retrieved with Ajax. However, you may use an error box at the top of the screen describing the problem. Or you may simply post the form using Ajax instead of a page refresh, then using JavaScript, you can display the errors to the appended input.
If this is not an answer to the question you are asking, please provide code and more details.

Angularjs default action form submit

My angular application needs to submit a form to a vendor. They then redirect the user to a page that I specified earlier in the process.
So I want standard, non-angular html form submit behaviour.
The documentation (details below) makes it sound like all I need to do is add an action attribute to my form element. I have tried this and it does not work.
Has anyone used this functionality in angular? Is there another step that I am missing?
The relevant section of the documentation at https://docs.angularjs.org/api/ng/directive/form is:
Submitting a form and preventing the default action
Since the role of forms in client-side Angular applications is different than in classical roundtrip apps, it is desirable for the browser not to translate the form submission into a full page reload that sends the data to the server. Instead some javascript logic should be triggered to handle the form submission in an application-specific way.
For this reason, Angular prevents the default action (form submission to the server) unless the element has an action attribute specified.
Angular does that. When you provide an action on the form, it should do exactly what you're trying to do (do a javascript thing, then submit the form).
Here is a plunk
In the plunk, you can see the $scope.submitted say 'submitted' just before the form submission kicks the page over to the submitted.html

How to render return HTML content after GWT form submit successfully

I want to mimic the traditional form submit in GWT via FormPanel, but the page can't redirect to the action Servlet in one HTTP trip, that is , submit is one trip, if you window.location.assign makes another. Even though I can have the result html via submitCompleteEvent.getResult which could not be rendered properly.
this question does not help me out.
So I split this question:
1. Can I really mimic HTML Form behavior by GWT FormPanel, which triggers the go-to action page on submit ?
2. How can I utilize the returning html from form successful submit ?

Form submit to iframe on new page

I have a form which submits to an iframe, This works fine if you are on a page with the iframe.
I want to be able to have the form on any page and when submit is pressed load a page and send the submit to the iframe
e.g.
On page "article.php" and press submit
Open page "results.php" and
Send post data from form clicked in "article.php" to iframe "DataHere" on "results.php"
Thanks in advance
You could try detecting if the frame exists when the form is submitted and if it does not, reload the whole page and generate the iFrame.
If you need a hand checkout http://www.java-scripts.net/javascripts/Check-Frames-Page-Script.phtml
If you are able to comfortably sanitize your initial POST data to avoid XSS, you could create an intermediate page for your iframe destination that does your POST for you:
On page article.php with <form action="results.php">, press submit.
results.php validates that the input isn't XSS, and renders with a <iframe src="negotiator.php?my=form&data=here"></iframe>
negotiator.php takes the query string arguments (and runs the same sanitizing as results.php) and POSTs them to your intended url.
Your results will load in the iframe.
It's pretty important that you make sure your input isn't insane. If your form requires arbitrary text, punctuation, and special characters, this is not safe for you.

Form Repopulation on Redirect using ASP

I'm currently working on an application that uses ASP, and I am currently having difficulty repopulating the fields of a form after redirecting back to that form.
Basically, I have a form where a user can input data into it (Say, an admin creating a new user within the system). Upon clicking the "Submit" button on the form, it goes to a processing page (say, userproc.asp) where it does input validation and adds the user to the database.
My issue is when the input validation fails, the application needs to return the user to the Form, report the issue, and keep the form populated as it was before clicking on submit.
This is where my problem lies, as I cannot find a good way to get a form to repopulate properly upon redirecting back to it using ASP. We do not want to use Javascript either.
Any thoughts/suggestions?
Make the Action for the Form point to itself instead of to a different "processing" page.
Remove the "processing" code that performs the validation and "user creation" for the "processing" page and place it in a Class defined in a new ASP page. This page is code only (just contains this class).
Include the new Class asp file in the orginal form page. On receiving a post instantiate the class and call an "Process" method where all your original code will work.
Have the method return some indication of success. If it has succeeded now you could either redirect to a "success page" or simply include the success markup in the form page. If the processing is failed you return your original form with the addition that you can set the values for all the fields to the ones received.