From 187eb2e9a1a00f2736a52076810adf15ff624e84 Mon Sep 17 00:00:00 2001 From: Alvaro Campos Date: Tue, 14 Feb 2012 19:04:46 -0400 Subject: [PATCH] BUG 8334 was added to the grid the functionality of checkbox --- gulliver/js/grid/core/grid.js | 9 +++++--- gulliver/system/class.form.php | 21 +++++++++++++++---- gulliver/system/class.xmlform.php | 19 +++++++++++------ .../xmlform/dynaforms/fields_ToolbarGrid.xml | 10 ++++----- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/gulliver/js/grid/core/grid.js b/gulliver/js/grid/core/grid.js index 45aa36008..66cbc8049 100755 --- a/gulliver/js/grid/core/grid.js +++ b/gulliver/js/grid/core/grid.js @@ -307,9 +307,12 @@ var G_Grid = function(oForm, sGridName){ } } break; - case 'checkbox': //CHECKBOX - aObjects[n].checked = false; - aObjects[n].value = defaultValue; + case 'checkbox': //CHECKBOX + attributesFalse = elementAttributesNS(aObjects[0], ''); + if((defaultValue === attributesFalse.falsevalue) || (defaultValue==='')) + aObjects[n].checked = false; + else + aObjects[n].checked = true; break; case 'hidden': //HIDDEN if ((attributes.gridtype != 'yesno' && attributes.gridtype != 'dropdown') || typeof attributes.gridtype == 'undefined') diff --git a/gulliver/system/class.form.php b/gulliver/system/class.form.php index f45b040a0..f1d02829f 100755 --- a/gulliver/system/class.form.php +++ b/gulliver/system/class.form.php @@ -316,6 +316,7 @@ class Form extends XmlForm break; case 'checkgroup': + case 'listbox': if ( is_array($newValues[$k]) ) { $values[$k] = $values["{$k}_label"] = ''; @@ -534,13 +535,25 @@ class Form extends XmlForm function validateFields($data) { $values = array(); $excludeTypes = array('submit', 'file'); - foreach($this->fields as $k => $v) { - if (!in_array($v->type, $excludeTypes)) { - switch($v->type) { - case 'checkbox': + if (!in_array($v->type, $excludeTypes)) { + switch($v->type) { + case 'checkbox': $data[$v->name] = isset($data[$v->name])? $data[$v->name] : $v->falseValue; break; + case 'grid': + $i = 0 ; + foreach ($data[$v->name] as $dataGrid) { + $i++; + foreach ($v->fields as $dataGridInt) { + switch($dataGridInt->type) { + case 'checkbox': + $data[$v->name][$i][$dataGridInt->name] = isset($data[$v->name][$i][$dataGridInt->name])? $data[$v->name][$i][$dataGridInt->name] : $dataGridInt->falseValue; + break; + } + } + } + break; default: } } diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 150ca684e..c9372b831 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -2398,16 +2398,23 @@ class XmlForm_Field_Checkbox extends XmlForm_Field $r = 1; foreach ( $values as $v ) { $checked = (($v == $this->value) ? 'checked="checked"' : ''); - if($this->readOnly==='readonly' or $this->readOnly==='1' ){ + if($this->readOnly==='readonly' or $this->readOnly==='1' ) { $disabled = "disabled"; } - else{ + else { $disabled = ''; } - //$disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); - $html = $res = "NSDefaultValue()." ".$this->NSGridType()."/>"; - $result [] = $html; - $r ++; + if ($this->mode==='edit') { + $html = $res = "NSDefaultValue()." ".$this->NSGridType()."/>"; + $result [] = $html; + $r ++; + } + else { + //$disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); + $html = $res = "NSDefaultValue()." ".$this->NSGridType()."/>"; + $result [] = $html; + $r ++; + } } return $result; } diff --git a/workflow/engine/xmlform/dynaforms/fields_ToolbarGrid.xml b/workflow/engine/xmlform/dynaforms/fields_ToolbarGrid.xml index e413b8782..15102f0eb 100755 --- a/workflow/engine/xmlform/dynaforms/fields_ToolbarGrid.xml +++ b/workflow/engine/xmlform/dynaforms/fields_ToolbarGrid.xml @@ -32,12 +32,10 @@ Yes/No - - - + + + Checkbox + Date