0
我收到元數據封裝器的錯誤。 我有一個字段測試=>實體引用多個這是一個選擇列表。我得到以下錯誤EntityMetadataWrapperException:給出無效的數據值。確保它匹配所需的數據類型和格式。實體元數據封裝器
$account = entity_load_single('user', $user->uid);
$acc_wrapper = entity_metadata_wrapper('user', $account);
$list = $acc_wrapper->test->value();
$exists = FALSE;
if (!empty($list)) {
foreach ($list as $item) {
if ($item->nid == $form_state['storage']['node']->nid) {
$exists = TRUE;
break;
}
}
}
if (!$exists) {
if (!$list) {
$list = array();
$list[] = $form_state['storage']['node']->nid;
}
$acc_wrapper->test->set($list);
$acc_wrapper->save();