I had it a bit wrong.  It should be more like - note the Model in the
newInsert array
for ($i=0; $i < count($_POST['fieldName']); $i++){
  $newInsert['Model'][fieldName] = $_POST['fieldName'][$i]; // do this
foreach
field
  $this->Model->create($newInsert);
  $this->Model->Save();

}


@citrus - Va;idation is handled automatically by Save().  If you want
to catch it use:

if (!$this->Model->save()) {
  // handle validation errors
}

Geoff
--
http://lemoncake.wordpress.com


On Jul 12, 2:19 pm, citrus <[EMAIL PROTECTED]> wrote:
> What about validation? How can I handle it?
>
> On Jul 11, 5:51 am,GeoffFord<[EMAIL PROTECTED]> wrote:
>
> > If every filed (or at least one of them) in the repeating region is
> > required then you can simply make the arrays (name="fieldName[]") and
> > then loop over them in the back end with
>
> > for ($i=0; $i < count($_POST['fieldName']); $i++){
> >   $newInsert[fieldOne] = $_POST['fieldOne'][$i]; // do this foreach
> > field
> >   $this->Model->create($newInsert);
> >   $this->Model->Save();
>
> > }
>
> > On Jul 11, 5:17 am, Chris Barna <[EMAIL PROTECTED]> wrote:
>
> > > I have a form where I would like to allow a user to add as many values
> > > of one section as they want without having to reload the form. I'm
> > > imagining an ajax button on the bottom that will allow the user to
> > > just keep adding multiples of that section of the form. My question
> > > is, what would the best way to process this be? I've got the
> > > associations with different tables worked out but I don't know how I
> > > would code the backend for something like this. Could somebody offer
> > > any advice?
>
> > > --
> > > Chris Barna


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to