Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
litecodeai committed Feb 13, 2012
2 parents a9bd7d3 + 3ec51a1 commit feacd4b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion components/com_fabrik/models/elementlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,21 @@ public function render($data, $repeatCounter = 0)
$values = $this->getSubOptionValues();
$labels = $this->getSubOptionLabels();

$selected = (array)$this->getValue($data, $repeatCounter);
// $$$ hugh -- working on issue with radio and checkbox, where extra blank subitem gets added
// if nothing selected. this fix assumes that 'value' cannot be empty string for sub-options,
// and I'm not sure if we enforce that. Problem being that if we just cast directly to
// an array, the array isn't "empty()", as it has a single, empty string entry. So then
// the array_diff() we're about to do sees that as a diff.
// $selected = (array)$this->getValue($data, $repeatCounter);
$selected = $this->getValue($data, $repeatCounter);
if (is_string($selected)) {
if (empty($selected)) {
$selected = array();
}
else {
$selected = array($selected);
}
}
//$$$ rob 06/10/2011 if front end add option on, but added option not saved we should add in the selected value to the
// values and labels.
$diff = array_diff($selected, $values);
Expand Down Expand Up @@ -476,6 +490,12 @@ function getValue($data, $repeatCounter = 0, $opts = array())
//query string for joined data
$value = JArrayHelper::getValue($data, $name);
}
// $$$ hugh -- added this so we are consistent in what we return, otherwise uninitialized values,
// i.e. if you've added a checkbox element to a form with existing data, don't get set, and causes
// issues with methods that call getValue().
if (!isset($value)) {
$value = '';
}
$element->default = $value;
$formModel = $this->getForm();
//stops this getting called from form validation code as it messes up repeated/join group validations
Expand Down

0 comments on commit feacd4b

Please sign in to comment.