0

I want to create a node entity. This node contain a date field. So, how can I set the date value ? (using entity_metadata_wrapper)

After several google search and code try, I don't find the solution.. My last try :

$date_temp = new DateTime(date('2013-12-01 00:00:00'));
$new_devicew->field_top[0]->field_date->set($date_temp->getTimestamp());

But i get this error :

EntityMetadataWrapperException : Unable to set the data property field_date as the parent data structure is not set. in EntityStructureWrapper->setProperty()

  • 1
    The error is telling you that $new_devicew->field_top[0] is not a wrapped entity object. Make sure field_top[0] is returning you the expected entity – Clive Jul 17 '14 at 12:07
  • I am not 100% sure if Date is fully compatible with EntityMetadataWrapper. I need to find some scripts I have to verify this. – mpdonadio Jul 17 '14 at 12:13
  • I see, thanks ! Its a new entity, so.. the first "field_top" doesn't yet exist Can you tell me how do I "create" the first "field_top" before I set the field date ? – user2137454 Jul 17 '14 at 12:14
  • MDP => after google search, Date and EntityMetadataWrapper seems ok But I maybe wrong – user2137454 Jul 17 '14 at 12:15
  • What is field_top? – kiamlaluno Jul 18 '14 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.