diff --git a/models/behaviors/linkable.php b/models/behaviors/linkable.php index 4f71156..cb0622b 100644 --- a/models/behaviors/linkable.php +++ b/models/behaviors/linkable.php @@ -259,12 +259,17 @@ class LinkableBehavior extends ModelBehavior { // in either/or, but a couple should include BOTH the // options AND the association settings. foreach (array('fields', 'conditions') AS $fld) { - if (!empty($options[$fld]) && !is_array($options[$fld])) + if (empty($options[$fld])) + $options[$fld] = array(); + elseif (!is_array($options[$fld])) $options[$fld] = array($options[$fld]); - if (!empty($association[$fld]) && !is_array($association[$fld])) + + if (empty($association[$fld])) + unset($association[$fld]); + elseif (!is_array($association[$fld])) $association[$fld] = array($association[$fld]); - if (!empty($options[$fld]) && !empty($association[$fld])) + if (isset($options[$fld]) && isset($association[$fld])) $options[$fld] = array_merge($options[$fld], $association[$fld]); }