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 - V
What about validation? How can I handle it?
On Jul 11, 5:51 am, Geoff Ford <[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 ($
Is there something special about foreach(). I modified it to use
foreach() rather than just for(). It seems to loop through just fine
but it saves over itself if there is more than one.
foreach ($this->data["FieldName"] as $field) {
$this->Model->create($field);
$this->Model->save();
}
On Jul 1
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
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 w