I have a Wicket Form and in this form there are components and panel(contains few components). When i do reset using formComponent.clearInput(), it resets only form components but not components inside panel.
Please let me know how to reset panel components also.
Ideally your components should be driven by the same model objects that are behind the form. That means you don't need to explicitly reset them at all, only add them to the AjaxRequestTarget if you want to refresh them during the serving of an ajax request.
FormComponent.clearInput() clears the request parameter that feeds this form component, a.k.a. its input. And it clears only this form component.
You have to use Form.clearInput() to clear the inputs for all FormComponent's in this Form.
FeedbackPanel.getFeedbackMessages().clear();
Read more
Component API and FeedbackMessages API
Related
I have a submit form that is once displayed in a PopUp and once shown normal on the page. So I created it in a storage folder and used "insert record" for said plugin twice.
When I submit one of the shown forms, it will be executed twice. Anyone ever had this kind of problem?
The contact request form is selfmade.
You need to distinct your two plugins from each other. I assume you have two times the same plugin on the same page. If you submit your form, both of the plugins respond to the request, because they both feel responsible for it.
If you could give one of the plugins a different name, it would just respond to its own form, and the other plugin would not respond to the other plugins form.
try to modify your plugin so you can configure it to only show the form.then you use two different CEs: one to show only the form, the second to show the form and to handle the submit.
Other possibility: while you are handling the form store the information about handling somewhere and avoid a second handling on the same call
When I make dynamic URLS in AJAX calls (based on some field value) then how to make HDIV work with this? Since the URL is dynamic HDIV won't know about this URL on server side. This would fail ultimately. Also we couldn't add it to exceptions. Then how to make it work?
These are some options:
Render all possible links, with all possible parameter values. Keep them hidden and choice the right one by JavaScript before submit.
Use a form instead of a link. You can create a hidden form and add multivalue parameters as select fields. Select the right values by JavaScript before submitting the form.
If the previous options are too complex, define the parameter as a startParameters. But note that it will not be validated.
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 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
I have working user registration form.
It consist of Zend Form Elements.
Now I wonder what is the best way to modify this form in order to implement a "switch" in registration form. In other words user should be able to choose which fields to fill (there should be fields as for individual user and company; only few elements should change their labels and "required" state of a selected registration type) and accordingly of made choice validate appropriate fields.
So which is the best and not hard way to make it?
Maybe there are some tutorial or examples?
Thank you!
I think that the best place to change required" states and validators of your form elements is just before validating your form, i.e. $yourForm->isValid($_POST). In this place you would have to change the validators and/or required states of some fields. Which fields would depend on the value of registration type input form element.
As far as showing/hiding specific form elements goes, you could do it on the front-end side using JavaScript.