Wicket: Loosing form input on page re-render - wicket

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

Related

tx_form multiple times on one page via RECORDS

via TypoScript i generate a HTML-Table and on every line i add the same formular (tx_form formular) via RECORDS. The form can be opened in a lightbox and all is fine but when i submit one of these, all forms will be submit and i receive 16 mails.
How can i separate the forms? RECORDS is needed because i build the table in TypoScript and so i can update the form in the backend and all forms on the page are updated.
Is there a parameter which i can set unique via TypoScript for every record so every form is technical a single form?
I would use some javascript to iterate over the forms and make them unique.
As this might conflict with the secutrity mechanism from TYPO3 you alternatively can use javascript to remove other than the currently clicked form from the page. This might need a reload from the page if you have no special answer page for the form.

Kentico and add Form that posts to external source

I want to create a Salesforce Web to Case from on my Kentico Site.
I have a template built and am inheriting the from that.
I create a new page and then add my form code to the Page Tab > Source and Save.
When I load the page on my site, the form is displayed, but when I hit submit, the form does not do the post action.
How do I accomplish this?
TIA, Jason
Since Kentico is built on web forms, each page's content is wrapped inside a form tag.
Adding your markup (including a form tag) in the middle of a Kentico page results in a nested form, which is invalid.
The quickest way to make this work is probably:
Create a basic HTML document with your markup, and put it on a new page in a "Custom Response" web part. https://www.screencast.com/t/PuwwnFTGGpAJ
Then display that new document in an iframe on your current page.
If that won't work, you can put your form markup in a div hidden by CSS. Then use javascript to move the div to a location after the page's main form tag. You can then use CSS to absolutely position the form on the page.
I hope this is helpful, good luck.

Dynamic show fields Symfony2

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.

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 do I make a link that pre-fills a form checkbox?

I have a page called contact.htm with a working form. One of the checkbox fields on the form is named Garden (so either it is checked or not when using the form).
I have another page that I want to link to my form page, so that if a user clicks a particular link, they are sent to the form page and the field Garden is pre-clicked.
I have not been able to do this though I have tried several methods...such as:
a href="contact.htm?checkbox=Garden,on" or
a href="contact.htm?checkbox=Garden,checked" or
a href="contact.htm?input type="checkbox" name="Garden" value="checked", and some others.
I would appreciate any help.
You'll need to use JavaScript on the target webpage to process the argument and fill the values in. There is no automatic way of doing this just by URL.
This link shows how to retrieve URL arguments from JavaScript. From there, it's a matter of using standard JavaScript or JQuery to fill the values in.