Not able to save the selected custom populated option list I have a cck select list where the options are populated by my custom code. There is no issue for populating the list but after that the selected options are not able to save. Is there any way to fix this. Here is my code snippets:

function pelikan_common_form_alter(&amp;$form, $form_state, $form_id) {
if ($form_id =='monitoring_node_form'){
    $nid = arg(3);
    $node = node_load($nid);
    $index=0;
      foreach ($node-&gt;field_test_monitoring['und'] as $key) {      
       $show = node_load($key['nid']);
       $form['field_indicator']['und']['#options'][$index++]= $show-&gt;title;

     }
   }
List fields are tied to their allowed values and they make sure all the values in the database align with what is in the allowed values.

To programatically populate list fields, there is a lesser known feature, which is that you can set the 'allowed_values_function' setting of your field instance.

If you are programatically creating your field you just add it in the settings.
If not you could do one of these things:


Form alter the field settings form to make the allowed_values_function field a visible text field you can enter a function name into.
Implement hook_enable() in your custom module to load the fields in question and set the allowed_values_function and then save the fields. Then use hook_disable() to reverse the cahnge when you disable the module.
Go in the database directly and set the value in the field settings.


Your allowed value function should be of the form:

function function_name($field, $instance, $entity_type, $entity, $cacheable) {
  // return an array of values.
  $values = array(
    'val1' =&gt; t('Value 1'),
    'val2' =&gt; t('Value 2'),
    'val3' =&gt; t('Value 3'),
  );

  return $values;
}


There is another module though that makes things a little nicer: List field predefined options

It allows you to implement it's hook to define allowed value functions, which you can then select from in the field UI.

For example:

/**
 * Provide information about available predefined list options.
 *
 * @return
 *   An associative array whose keys define the machine name for each
 *   predefined list options and whose values contain the list options
 *   descriptions. Each list options description is itself an associative
 *   array, with the following key-value pairs:
 *   - 'label': (required) The human-readable name of the list options.
 *   - 'callback': (required) The name of the function that will return the
 *     list options.
 *
 * @see hook_list_option_info_alter()
 */
function MYMODULE_list_option_info() {
  $info['FIELD_NAME'] = array(
    'label' =&gt; t('Name that describes the values this callback will return'),
    'callback' =&gt; 'mymodule_function_that_returns_allowed_values',
  );

  $info['ANOTHER_FIELD_NAME'] = array(
    'label' =&gt; t('Name that describes the values this callback will return'),
    'callback' =&gt; 'mymodule_another_function_that_returns_allowed_values',
  );

  return $info;
}


Then you can implement the functions you defined in the above hook to return the allowed values and in the field UI you can select to use the function by its label.
Much more user friendly.