21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 168 Views |
-
RESOLVED: Model Admin Associating Image

9 October 2012 at 11:55pm
I'm hoping someone is going to be able to shed some light on an issue I'm having with ModelAdmin. I using ModelAdmin to manage data associated with a jquery carousel.
Here is what I have:
Data Object
<?php
class CarouselItem extends DataObject {
static $db = array(
'Caption' => 'Text',
'URL' => 'Varchar(255)'
);
static $has_one = array(
'Photo' => 'Image'
);
static $summary_fields = array(
'URL',
'Created',
'LastEdited'
);
}?>
ModelAdmin code
<?php
class CarouselAdmin extends ModelAdmin
{public static $managed_models = array(
'CarouselItem'
);static $url_segment = 'carousel';
static $menu_title = 'Carousel Data';
}?>
The above seems to work ok when it comes to saving the CarouselItem apart from the relationship to the image. The $has_one seems to create a PhotoID field on the CarouselItem table however this is the only field that is not updated when managing this data. Also I get a quick fade in message when attempting to select an image - the message that fades in is "Forbidden".
Am I missing something here ?
Any assistance would be greatly appreciated.
-
Re: RESOLVED: Model Admin Associating Image

10 October 2012 at 11:06pm
I discovered there was actually nothing wrong with the code. It's was simply a matter of saving the new record before adding the image to it. I guess SS had a hard time trying to associate the image to a record that didn't exist yet.
| 168 Views | ||
|
Page:
1
|
Go to Top |

