diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 6709b7a75f628bf4917b955d9bc4a0241d6e19ee..43ae645c765a97524d7479e6995c5261319d522d 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -153,6 +153,14 @@ class DynamicForm extends VerySimpleModel { return $inst; } + function disableFields(array $ids) { + foreach ($this->getFields() as $F) { + if (in_array($F->get('id'), $ids)) { + $F->disable(); + } + } + } + function getTranslateTag($subtag) { return _H(sprintf('form.%s.%s', $subtag, $this->id)); } @@ -986,15 +994,18 @@ class DynamicFormEntry extends VerySimpleModel { function getForm() { if (!isset($this->_form)) { // XXX: Should source be $this? - $form = new SimpleForm($this->getFields(), $this->getSource(), + $fields = $this->getFields(); + if (isset($this->extra)) { + $x = JsonDataParser::decode($this->extra) ?: array(); + foreach ($x['disable'] ?: array() as $id) { + unset($fields[$id]); + } + } + $form = new SimpleForm($fields, $this->getSource(), array( 'title' => $this->getTitle(), 'instructions' => $this->getInstructions(), )); - if (isset($this->extra)) { - $x = JsonDataParser::decode($this->extra) ?: array(); - $form->disableFields($x['disable'] ?: array()); - } $this->_form = $form; } return $this->_form; diff --git a/include/class.forms.php b/include/class.forms.php index 602a5f4af7036b2018cc1e4dda241efb9122d0a6..202948ed8ebdfc2461e69ffacb996eced512fd5a 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -127,14 +127,6 @@ class Form { return $this->_clean; } - function disableFields(array $ids) { - foreach ($this->getFields() as $F) { - if (in_array($F->get('id'), $ids)) { - $F->disable(); - } - } - } - function errors($formOnly=false) { return ($formOnly) ? $this->_errors['form'] : $this->_errors; } diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index 834cc5a72b3b831616e0a49febb1e3277a4670a1..f6dbcfe7bb813d619ccbf60043e9ab2a940457fb 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -370,7 +370,7 @@ foreach ($forms as $F) { <th><?php echo __('Variable'); ?></th> </tr> <?php - foreach ($F->getFields() as $f) { ?> + foreach ($F->getDynamicFields() as $f) { ?> <tr> <td><input type="checkbox" name="fields[]" value="<?php echo $f->get('id'); ?>" <?php @@ -440,21 +440,20 @@ $(function() { } }); }); - + $('table#topic-forms').sortable({ + items: 'tbody', + handle: 'td.handle', + tolerance: 'pointer', + forcePlaceholderSize: true, + helper: function(e, ui) { + ui.children().each(function() { + $(this).children().each(function() { + $(this).width($(this).width()); + }); + }); + ui=ui.clone().css({'background-color':'white', 'opacity':0.8}); + return ui; + } + }).disableSelection(); }); -$('table#topic-forms').sortable({ - items: 'tbody', - handle: 'td.handle', - tolerance: 'pointer', - forcePlaceholderSize: true, - helper: function(e, ui) { - ui.children().each(function() { - $(this).children().each(function() { - $(this).width($(this).width()); - }); - }); - ui=ui.clone().css({'background-color':'white', 'opacity':0.8}); - return ui; - } -}).disableSelection(); </script>