Parameter Map - Remove option if already used


(Nic Hubbard) #1

I am using a Parameter Map and if one of the mapping options is used it still shows that option on the drop down. I don't want the user to be able to choose an option twice.

 

Here is what I have tried, but it always results in errors and problems with the parameter map:

 

 

$parameter_map_value = array_get_index($settings, 'value_map', serialize(Array()));
$atr_parameter_map = new Asset_Attribute_Parameter_Map(0, $parameter_map_value);

// Param Map
$current_params = $atr_parameter_map->getParameters();
if (!in_array(‘value_map_token’, $current_params)) {
$atr_parameter_map->setParameter(‘value_map_token’, ‘Device Token’);
}
if (!in_array(‘value_map_badge’, $current_params)) {
$atr_parameter_map->setParameter(‘value_map_badge’, ‘Badge’);
}

 

This will throw an undefined index error because if the option has previously been chosen, then in the code I don't want to set the parameter again. But, looks like it doesn't work that way.

 

Any ideas?