Thursday, March 28, 2013

Re: Multiple Forms on the same form

I have done this using AJAX.  Have the button fire an AJAX event which calls an action on your controller which returns an empty workcenter section of the field.  Pass in to the AJAX call an index and have the form fields specified using the index.  When the form is submitted you would then have an array of workcenters as part of your data and you can use saveAll to save the factory model and all related models (assuming you have set up a hasMany / belongsTo relationship between factory and workcenter).

Just remember that when editing a factory you will need to present all of the existing workcenters associated with it as well.

On Sunday, March 24, 2013 7:54:37 PM UTC+2, Steven Scaffidi wrote:
Let's say I had a model called factory, and I wanted to add multiple workcenters to the factory. When I go to add a new factory, I want a button on the bottom of my form that says add workcenter. I want that button to be always there just in case they want to add multiple work centers. I don't want the form for workcenter to appear until they click the button add workcenter. How can I accomplish this?


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: