Closed (fixed)
Project:
Campaign Monitor
Version:
7.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Dec 2012 at 04:49 UTC
Updated:
18 Jan 2013 at 22:10 UTC
All checked options from the custom field should remain checked after the form/block is submitted.
Only the last checkbox selected when the form was submitted remains checked.
This issue appears to be caused from a defect in the getSubscriber method of campaignmonitor.class.inc.
Specifically this code:
foreach ($result->response as $key => $value) {
if ($key == 'CustomFields') {
// Convert the custom fields object into a keyed array.
$this->subscribers[$listId . $email][$key] = array();
foreach ($value as $field) {
$this->subscribers[$listId . $email][$key][$field->Key] = $field->Value;
}
}
else {
$this->subscribers[$listId . $email][$key] = $value;
}
}
Changing the block above to the following seems to fix the problem:
foreach ($result->response as $key => $value) {
if ($key == 'CustomFields') {
// Convert the custom fields object into a keyed array.
$this->subscribers[$listId . $email][$key] = array();
foreach ($value as $field) {
// Check if the field has been set. If not, set the value.
if(!isset($this->subscribers[$listId . $email][$key][$field->Key])){
$this->subscribers[$listId . $email][$key][$field->Key] = $field->Value;
}
// If the field HAS been set, and there are additional values, check if the field is NOT an array?
else if(! is_array($this->subscribers[$listId . $email][$key][$field->Key]) ) {
// If the field is not an array, assign an array to the field, containing the previous value of the field and this new value.
$this->subscribers[$listId . $email][$key][$field->Key] = array($this->subscribers[$listId . $email][$key][$field->Key], $field->Value);
}
// If the field is an array and there is an additional value, append it to the field rather than overwriting the field value.
else {
$this->subscribers[$listId . $email][$key][$field->Key][] = $field->Value;
}
}
}
else {
$this->subscribers[$listId . $email][$key] = $value;
}
}
Comments
Comment #1
cableman0408 commentedThanks for the fix, it will be part of the next release :-)