Skip to content
Snippets Groups Projects
Commit 282a0c97 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge pull request #1816 from protich/issue/external-fields


Dynamic form entry fields  

Reviewed-By: default avatarJared Hancock <jared@osticket.com>
parents 386ea8fe ae02af9a
No related branches found
No related tags found
No related merge requests found
......@@ -706,11 +706,23 @@ class DynamicFormEntry extends VerySimpleModel {
function getFields() {
if (!isset($this->_fields)) {
$this->_fields = array();
// Get all dynamic fields associated with the form
// even when stored elsewhere -- important during validation
foreach ($this->getForm()->getDynamicFields() as $field) {
$field->setForm($this);
$this->_fields[$field->get('id')] = $field->getImpl($field);
}
// Get answers to entries
foreach ($this->getAnswers() as $a) {
$T = $this->_fields[] = $a->getField();
$T->setForm($this);
if (!($f = $a->getField())) continue;
// Perhaps an answer of deleted field
if (!isset($this->_fields[$f->get('id')])) {
$f->setForm($this);
}
$this->_fields[$f->get('id')] = $f;
}
}
return $this->_fields;
}
......@@ -890,7 +902,7 @@ class DynamicFormEntry extends VerySimpleModel {
$a->deleted = false;
// Add to list of answers
$this->_values[] = $a;
$this->_fields[] = $field;
$this->_fields[$field->get('id')] = $field;
$this->_form = null;
// Omit fields without data
......
......@@ -962,7 +962,7 @@ class ChoiceField extends FormField {
$config = $this->getConfiguration();
if (!$config['multiselect'] && is_array($value) && count($value) < 2) {
reset($value);
return key($value);
$value = key($value);
}
return $value;
}
......@@ -1899,9 +1899,12 @@ class ChoicesWidget extends Widget {
}
function getValue() {
$value = parent::getValue();
if (!$value) return null;
if (!($value = parent::getValue()))
return null;
if ($value && !is_array($value))
$value = array($value);
// Assume multiselect
$values = array();
......@@ -1912,6 +1915,7 @@ class ChoicesWidget extends Widget {
$values[$v] = $choices[$v];
}
}
return $values;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment