Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents a9bd7d3 + 3ec51a1 commit feacd4b08aaa28a3aab9d29fc1c4a64247752733 rw1 committed Feb 13, 2012
Showing with 21 additions and 1 deletion.
  1. +21 −1 components/com_fabrik/models/elementlist.php
@@ -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);
@@ -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

0 comments on commit feacd4b

Please sign in to comment.