By default select options i have left empty in admin of that content type.
I am trying to alter select list option of a content type using hook_form_alter.
I am setting the values to select values and is getting assigned.
Only issue is that its getting logged out with single refresh to create form of that content type form or try to submit that form. What am i doing wrong in the code.
Thanks in advance.
function hook_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'product_node_form') { $users = db_select('users', 'u'); $users->join('users_roles','ur','u.uid = ur.uid'); $users->fields('u',array('name')); $users->fields('ur',array('uid')); $users->condition('ur.rid',6,'='); $users->orderBy('u.uid'); $users = $users->execute()->fetchAll(); $vendor_list = array("Tan" => "Tan"); foreach($users as $key => $user) { $vendor_list[$user->name] = $user->name; } $form['field_publish_to']['und']['#options'] = $vendor_list; } }