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
Related
I have pages with forms. Everything is working fine. Except, that there is a link (language selecter) on the pages. The requirement is, that when the user has already input in the form fields and than (without submitting the form) is clicking the link, all input should be retained.
If the link would be part of the form, this could easily archived via a SubmitLink and submitLink.setDefaultFormProcessing(false);
Unfortunately, this link has no knowledge of the form(s) on this page.
Any pointers if this is solvable? Of course, validation should not be triggered.
client-side JavaScript solution
wrap complete page content in a form
(yes, Wicket allows nesting of forms) and use an SubmitLink with
defaultFormProcessing=false
add an AjaxFormComponentUpdatingBehavior
to all your form fields, so the input is always sent to the server
I trying to add some fields to form depending of checkbox. But I have no idea how can I do that. I think Ajax can be useful, but I dont work with Ajax in Symfony2 yet, and if my form build up not in the controller what value I need specify in url: option of Ajax?
That's quite a broad question, but essentially: the Symfony way is to add them to the Form in the Controller by reacting to FormEvents.
Symfony Docs on Form Events
One way to achieve what you're after is to submit the form twice - the first time code will react to the checked checkbox and arrange the rest of the form as required, the second time the form will be valid and you can take action. Details on the above link. AJAX might help with this, allowing a form submission as soon as you've checked the checkbox.
Although you can create HTML form fields using AJAX, when you submit the form those fields need to exist in the Form object. You can add them just in time, in the controller, before Symfony tries to bind them.
My company's app builds simple forms that people can use on their websites to get information into our app. We have a generic form response script that each of these forms submits to, to gather and parse the webform responses.
We're encountering form values that look a lot like the values in Google Analytics cookies (utmz, utmsc, utmccn) The cookies are clearly not part of the form fields. The form is being done with a simple HTML form submit, so I'm at a loss how these values are getting appended on to the post.
Here's a sample form submission:
http://website.com/submit.php?&clientGuid=2342342abcde23423423&webformid=12&prospect_id=12345&custom_Register_or_Dance_the_Chicken=Register&__utma=84164169.205192989.1344888984.1346176569.1346178936.47&__utmc=84164169&__utmz=84164169.1344888984.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Under what circumstances would a browser submit cookies along with a form submit? Is there a way to prevent it?
This looks like cross-domain user tracking... From the Google Analytics docs for _linkByPost():
The _linkByPost() method passes the GATC cookies from the referring form to another site in a string appended to the action value of the form (HTTP POST).
If there's no onsubmit='...' code directly on the form, it might be attached via jQuery or some other method.
It may be due to Google Chrome adding them to your form variables on submission...
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 ?
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.