Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObject already in DataObjectSet?


Go to End


3 Posts   1462 Views

Avatar
baba-papa

Community Member, 279 Posts

20 January 2010 at 1:50pm

How can I check if a DataObject is already in a DataObjectSet? I tried in_array() but it can´t cope with object sets.

Avatar
Willr

Forum Moderator, 5523 Posts

20 January 2010 at 6:02pm

Edited: 21/01/2010 8:49am

You could try using containsIDs() and passing in the ID of your dataobject or you could use find().

$set->containsIDs(array($object->ID));

// or

$set->find('ID', $object->ID);

Avatar
baba-papa

Community Member, 279 Posts

21 January 2010 at 12:42am

Great, thanks willr.