I have a content type that has a field collection item, which is to be shown as select list. I am using hook_form_alter to do that. I also want a filter such that it picks node id from URL and sets values against that node to my select list. Here is my code:
$url_arg=arg();
$node_id=$url_arg[1];
$node=node_load($node_id);
$info = field_info_field('field_testing_code');
$values = &$info['settings']['allowed_values'];
$values= array();
I reinitialized the array to remove any existing values. Here is how I assigned values:
$i=0;
while($node->field_consignment_text_field[und][$i][value]){
$values[$node->field_consignment_text_field[und][$i][value]] = $node->field_consignment_text_field[und][$i][value];
$i++;
}
field_update_field($info);
Suppose I have 2 nodes A and B opened in two different tabs. A have field collection item values "11" and "22" while B has "33" and "44". On reloading both tabs it sets "11" & "22" or "33" & "44" to both tabs. On reloading one tab at a time, it gets correct value.
I think this is due to simultaneous calls to form_alter. How can I handle that? Is there any way to wait a process unless the other complete its execution?
Or any other solution?