Creating an eZEnumObjectValue

Author Message

Rib Rdb

Sunday 01 June 2003 8:21:40 pm

I'm trying to create a new content object with a single enum attribute. I use the following code to try to create an eZEnumObjectValue to store in the attribute:

$attributes = $version->contentObjectAttributes();
$enum = $attributes[0]->content();
$enumobjectList = $enum->attribute('enumobject_list');
$enumobjectList[0] =&
eZEnumObjectValue::create(
$enum->attribute('contentclass_attributeid'),
$enum->attribute('contentclass_attributeversion'),
$ids[$Rating],
$elements[$Rating],
$values[$Rating]);
$enumobjectList[0]->store();

The value appears to be stored to the database, but isn't associated with the object. The contentclass_attributeid always seems to be the id of the enum in the class definition, instead of an id specific to the instantiated object. I've tried this code both before and after publishing the object. Do I need to publish it and then fetch it to do this? Do I somehow need to create an attribute? What am I doing wrong?

Rib Rdb

Sunday 01 June 2003 9:28:06 pm

Well, I got what I asked for. Here's the modified code that works, if anyone else is trying this:

$attributes = $version->contentObjectAttributes();
$attribute = $attributes[0];
$enum = $attribute->content();
$enumobjectList = $enum->attribute('enumobject_list');
$enumobjectList[0] =&
eZEnumObjectValue::create(
$attribute->attribute('id'),
$attribute->attribute('version'),
$ids[$Rating],
$elements[$Rating],
$values[$Rating]);
$enumobjectList[0]->store();

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.