Skip to content

Commit

Permalink
fixed issue with MY_Model::replace_placeholder method
Browse files Browse the repository at this point in the history
  • Loading branch information
David McReynolds committed Oct 23, 2014
1 parent b4a7254 commit 1bcfc08
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions fuel/modules/fuel/core/MY_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,6 @@ public function form_fields($values = array(), $related = array())
$order = $rel_config['order'];
}
}

$related_model = $this->load_related_model($rel_config);
$related_options = $CI->$related_model->options_list(NULL, NULL, $where, $order);
$related_vals = ( ! empty($values['id'])) ? $this->get_related_keys($values, $related_model, 'belongs_to', $rel_config) : array();
Expand Down Expand Up @@ -4139,6 +4138,8 @@ protected function _is_nested_array($record)
*/
public static function replace_placeholders($str, $values)
{
$return = $str;

if (is_string($str))
{
if (strpos($str, '{') !== FALSE)
Expand All @@ -4163,9 +4164,24 @@ public static function replace_placeholders($str, $values)
$return = array();
foreach($str as $key => $val)
{
if (isset($values[$key]))
if (strpos($val, '{') !== FALSE)
{
if (!empty($values))
{
foreach($values as $k => $v)
{
$return[$key] = str_replace('{'.$k.'}', $v, $val);
}
}
else
{
// returns nothing to prevent SQL errors
$return = array();
}
}
else
{
$return[$key] = str_replace('{'.$key.'}', $values[$key], $val);
$return[$key] = $val;
}
}
}
Expand Down

0 comments on commit 1bcfc08

Please sign in to comment.