Submitting multiple forms from a single view - forms

Using CakePHP I have a page where I have multiple forms. Each form updates a single field on a record. I'm trying to implement a way to submit all the forms through a single "Submit All" button. However, all my solutions so far have been lest than successful.
My first attempt was to create a separate action called editAll in the controller that took an array, but I cannot figure out how to send the data from all the forms to that action without having a hidden form that saves all that data. The second idea was to create some kind of Javascript function that iterated over all the forms to create an array to be sent to the controller's editAll action.
The first implementation did not work, and I couldn't find a reasonable way to implement the second idea.
Basically, I was hoping someone could point me in the direction to submitting multiple forms (or at least the data from multiple forms) at once from a single page.

I assume you don't ALWAYS want to submit them all - if you do, then just make one form. If you're hoping to be able to submit some of them individually, but also be able to submit them all, then you could do something along the lines of this:
Keep all the fields in one form. For each field have a 'submitted' value (1 or 0). If they click the Submit next to an individual field, turn all of the submitted values to 0 except that one, then submit the form.
If they click Submit All, then turn them all to '1' and submit the form.
Then, when you process the data, just strip anything that doesn't have 'submitted' value of 1.
It would still take some work, and you're submitting more data than is necessary, but.... it's an idea.

Related

Drupal - edit a form without a hook_form_alter?

Here is my problem :
I have a checkout page with multiple forms, the first one is for add people to the order, and the second one is the checkout form. I need to get the people from the first form in my second form, the problem is that these two forms are created when the page is loaded, so at the beggining the second form doesn't know who are the people in the first form, so I can't use form_alter (or only if I refresh the page).
I think the thing to do is add them when the first form is submitted, but how to alter fields of another form ?
Edit:
Yes same page, so i really can't use the form_alter, I try this thing now : ajax_command_replace('#commerce-checkout-form', drupal_render(drupal_get_form('commerce-checkout-form', $order, $payment_page)));
but the drupal_render returns me an empty form (I check with dsm) and it's not replaced in the page
I also try to set a callback on my checkbox field and do a form_rebuild on the callback but doesn't work too... I really don't know how to do that
Do you have any idea of how to make this works ?

TYPO3 Contact form plugin exists twice, also submitted twice

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

How to update the responses of the google form to the form itself

I am creating a Google Form. I want to insert a count in the end(anywhere,not specific) of the form which will show the number of responses submit till date.This goes like updating the live count. I have tried using script editor for Google Form Add-ons option.But I am unable to view the results automatically or changes. It asks me to accept "Terms of Service" which I don't want to do right now because I am not sure about the way it may result.
There are various options available to view the form results/responses.But here I don't want to view the results later.They should get updated when we click the submit button on form.Please note..simultaneously many users may fill the form.
To implement this,I have thought of logic like whenever submit button gets clicked..the text in the form should get updated.
Please suggest how I can add the count or apply above logic of whenever submit operation is performed. Is it possible?? Any other suggestions are welcomed..Thanks in Advance!!!
I found another possible way of doing this..I received all the responses in Google Spreadsheet..which I later embedded in my site. Solves the purpose..And the embedded data gets updated automatically for the responses !! Cheers

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.

ASP.NET MVC 2: Emulating eBay Postback

Below is an image of the sections I'm talking about:
What I'm doing is very similar to eBay:
1) a form at the top for "search terms" and then a category.
2) filters on the left that a user can click to refine the search even further.
3) sorting those results.
I played with eBay a bit and it looks to me like they are posting back every time a filter (box on the left) is clicked, or when they sort the results. Do they then store a copy of all the "settings" used to display the page in the form and use that to post back on a submit click?
How can I emulate this functionality? I don't like the idea of wrapping an entire page in a form element... it seems dirty. Should I use jQuery to collect all of the user input and then somehow pass it along?
I'm not sure how eBay does it, but if it were me, I'd have some javascript object that keeps track of all the search options on the page. Each of the elements you've highlighted would fire an event that would cause my javascript object to update this information, send it via AJAX to a controller action, and update the results area with the changes.
That's a somewhat simplified version of events, but hopefully it can put you on the right track.
I've decided that the best solution is to use jQuery Ajax. Otherwise, I'd have to make sure that every peice of user input is a form element and wrap the entire page in a form tag.