Hi Forum,
i want to set a link field via entitywrapper, all my other fields are working with the following method:

$fc_item = entity_create('field_collection_item', array('field_name' => 'field_collection'));
$fc_item->setHostEntity($nodetype, $node);  
$fc_wrapper = entity_metadata_wrapper('field_collection_item', $fc_item);
$fc_wrapper->{'field_link'}->set($value);
//>$fc_wrapper->{'field_md_'.$subkey}->set((array)$file);.

This works for text and numeriacl fieldtypes or files but i want to set a link. So i have tested:

$fc_wrapper->{'field_link'}->set('www.example.org'); or
$fc_wrapper->{'field_link'}->set('http://www.example.org');

but it does not work for me.
Maybe some of you can help me.
thanks a lot
Andy

Comments

mmartinov’s picture

In case anybody arrives here by google (like me), the answer is:

$fc_wrapper->{'field_link'}->set(['title' => 'Link title...', 'url' => 'http://example.com']);

Replace [] with array() above if you're running an older version of php.