Okay this might sound simple but there’s a catch. I’ll try and explain the situation.
I have a page wich is build with a layout and in the center there’s a view with 2 buttons and a normal form. The 2 buttons are to switch between two input forms. When the submit is pressed both forms are submitted. The first form is for general information and the second one is used to upload an image along with the information if so desired.
Now to avoid the question why not use one form? it’s a request to keep the two seperated in this manner.
So i was considering going with 2 views where the top 2 buttons would act like a submit, creating a POST request with the form data but not actually submiting it to the database. And then redirecting towards the second view where you can upload images.
And then when the actual submit button is pressed i want all the data collected to be written into the database.
Basically it’s like a page with 2 Tabs with a form each and only 1 submit button to submit the forms on both tabs.
I just can’t get my head around how to create those 2 buttons to store the post data and then have the ‘final’ submit button use the previous post data and then other form data to create a new combined post data to store in the database.
Anyone have an idea how to accomplish this? Am i approaching this correctly or is there a simpler or cleaner method to doing this?
Thanks in advance!
You have a number of options here, one option is to create one form and add your two seperate sections as SubForms, i.e. instances of Zend_Form_SubForm. Then you can style the forms separately, tab them but keep one submit button for both. Also when you submit, the forms data will be separated into an array element for each of the sub forms.
you can see more about this here:
http://framework.zend.com/manual/en/zend.form.advanced.html#zend.form.advanced.multiPage
another solution i’m fond of is using an action helper to split the process of adding the forms into two pages, similarly to the url above but storing form information inside a session object until both have been validated and then processing both forms at once.
http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Action_Helper_Multiform+Proposal+-+Simon+Mundy
http://framework.zend.com/wiki/pages/viewpage.action?pageId=42130
hope this helps.