سؤال

I'm trying to develop a tutorial from http://www.ssbits.com that uses Dataobject as pages. Here's the link to it: http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple

Now in the tutorial (which I've used already in my projects) there's only one image per staff member, I want to associate 2 images per staff member (I've used products instead of staff members), I guess I need to use $has_many relation but when I try it doesn't work properly, it uploads the images but it doesn't associate them with the staff member (product in my case). Here's how I did it:

//Relations
static $has_one = array (
   'ProductPage' => 'ProductPage'
);

static $has_many = array (
  'Photo1' => 'Image',
  'Photo2' => 'Image'
);

Anyone knows how to do this?

Thanks
Mauro

هل كانت مفيدة؟

المحلول

just use has_one instead of has_many. you'd use has_many in case you wanted to have 'a bunch of images' but you need 'exactly 2'.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top