I am creating a node programmatically and I have a field which is autocomplete and has number of values set to unlimited.

In the code for adding the node programmatically ,the code is as given below

    $node->field_user[]['value'] = $user->name;
       $node->field_time[]['value'] = date('m-d-Y H:i', REQUEST_TIME);
  $trans_node->field_download_flag[0]['value'] = 'YES';

So after programmatically creating a view when I check into the 'find content' place I see a node being generated but when I click on the link(where the content title is )( not on the edit link) , I cannot see the field_user in the view list

type: date
widget : popup calendar
no of values : unlimited.

type: Entity Reference
widget : Autocomplete
no of values : unlimited.

type: boolean
widget : checkbox/radiobutton
no of values : unlimited.

I think the code for field_user should be as

$node->field_user[]['target_id'] =  $user->name;

but still i am getting error that is WSOD

  • Have you tried : $node->field_user['und'][]['target_id']
    – pico34
    Commented Aug 22, 2013 at 12:46
  • Can I assign user->name to target_id or should I assign it to $user->uid ?
    – harshal
    Commented Aug 22, 2013 at 12:48
  • target_id is for an uid reference
    – pico34
    Commented Aug 22, 2013 at 12:49
  • it works with $node->field_user['und'][]['target_id'] ..and now what about time field?
    – harshal
    Commented Aug 22, 2013 at 12:51
  • 1
    For boolean the column name is 'value', for date the potential names are 'value', 'value2', and another one to do with the timezone (can't recall the name off the top of my head)
    – Clive
    Commented Aug 22, 2013 at 13:12

1 Answer 1


I think




is the good way

  • for field_time i getting error .. even after using $node->field_time['und'][]['value'] ??
    – harshal
    Commented Aug 22, 2013 at 12:59
  • pls check the updated question I have also added boolean field...
    – harshal
    Commented Aug 22, 2013 at 13:01
  • enable devel module you'll be able to see the node object structure
    – pico34
    Commented Aug 22, 2013 at 13:05
  • is it present in the core>
    – harshal
    Commented Aug 22, 2013 at 13:06
  • 2
    lol no, i can't do it for u
    – pico34
    Commented Aug 22, 2013 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.