Using Cake 1.2 tried current stable release and nightly build
03-30-2008 .

I have a model Slideshow that has many Photos.

I have a view for creating a slideshow with multiple photos:

<div class="foto">
    <h2>New Postcard</h2>
    <?php echo $form->create('Slideshow', array('type' =>
'file','action' => 'save'));?>
    <?php echo $form->input('Photo.1.image', array('class' =>
'required', 'type' => 'file'));?>
    <?php echo $form->input('Photo.2.image', array('class' =>
'required', 'type' => 'file'));?>
    <?php echo $form->input('Slideshow.audio', array('class' =>
'required', 'type' => 'file'));?>
    <?php echo $form->submit('Submit');?>
    </form>
</div>

(I also tried setting up the form with the photo's nested: i.e.
input('Slideshow.Photo.1.image'))

in the Slideshow controller I did a:

$this->Slideshow->saveAll($this->data)

then it inserts a slideshow and two photos in there respective tables
but with no fields set aside from the created and modified fields, and
no foreign_key set for the photos. *Note all the fields of type file
have an upload behavior associated with them*

To get the results I wanted I did the following instead of using
saveAll, and it works fine (but I would prefer to use saveAll if it's
possible):

   if($this->Slideshow->save($this->data)) {


      $slideshow_id = $this->Slideshow->getLastInsertId();

      foreach($this->data['Photo'] as $index => $photo) {
        $photo = array('Photo' => $photo);
        $photo['Photo']['slideshow_id'] = $slideshow_id;


        $this->Slideshow-->Photo->create();

        $this->Slideshow->Photo->set($photo);
        $this->Slideshow->Photo->save();
    }

....

Any tips on how to get this functionality with saveAs??


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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