I have created content type named "site_profile", and form named "add_website_form". The content type includes cck fields and one of the fields is "field_operators" which is select box field. I have hooked options of the field to display variable that contains array of specific users with some mechanism. The hook_form_alter is:
function lcm_form_site_profile_node_form_alter(&$form, &$form_state, $form_id) {
$relevant_users = lcm_get_relevant_users();
$form['field_operators']['und']['#options'] = $relevant_users;
}
Now I am trying to get functionality that stores data into the node through node_save() function from the "add_website_form" (costume form).
the code that supposed to insert the data is:
function lcm_add_website_form_submit($form, &$form_state){
$website_name = $form_state['values']['website_name'];
$url = $form_state['values']['url'];
$operators_for_site = $form_state['values']['operators_for_site'];
lcm_add_website_form_insert_to_db($website_name, $url, $operators_for_site);
}
function lcm_add_website_form_insert_to_db($website_name, $url, $operators_for_site){
// Create a node object, and add node properties.
$new_website = new stdClass();
$new_website->type = 'site_profile';
$new_website->title = $website_name;
$new_website->uid = $GLOBALS['user']->uid;
$new_website->field_url['und'][0]['value'] = $url;
$new_website->field_operators['und']['value'] = $operators_for_site;
$new_website->created = strtotime("now");
$new_website->changed = strtotime("now");
$new_website->status = 1;
$new_website->comment = 0;
$new_website->promote = 0;
$new_website->moderate = 0;
$new_website->sticky = 0;
$new_website->language = 'und';
node_object_prepare($new_website);
// Save the node.
node_save($new_website);
}
the problem is that the data that supposed to save on field_operators doesn't save... Any ideas?