Permalink
Browse files

Forced SetValue

When issue summary is disabled for a specific help topic, the system uses
help topic name as the subject line.

Due to validation error on disabled subject field the setValue fails to take
in the help topic. The change here allows for forced value set.
  • Loading branch information...
protich committed Jun 17, 2016
1 parent a01f2cb commit 74bdc0237fcf0369e52b11ecb95ae391c9fade46
Showing with 22 additions and 18 deletions.
  1. +12 −8 include/class.dynamic_forms.php
  2. +7 −5 include/class.orm.php
  3. +3 −5 include/class.ticket.php
@@ -951,15 +951,11 @@ function getAnswer($name) {
}
function setAnswer($name, $value, $id=false) {
foreach ($this->getAnswers() as $ans) {
if ($ans=$this->getAnswer($name)) {
$f = $ans->getField();
if ($f->isStorable() && $f->get('name') == $name) {
$f->reset();
$ans->set('value', $value);
if ($id !== false)
$ans->set('value_id', $id);
break;
}
if ($f->isStorable())
$ans->setValue($value, $id);
}
}
@@ -1359,6 +1355,14 @@ function getValue() {
return $this->_value;
}
function setValue($value, $id=false) {
$this->getField()->reset();
$this->_value = null;
$this->set('value', $value);
if ($id !== false)
$this->set('value_id', $id);
}
function getLocal($tag) {
return $this->field->getLocal($tag);
}
View
@@ -1468,6 +1468,13 @@ function fillTo($level) {
}
}
function reset() {
$this->eoi = false;
$this->cache = array();
// XXX: Should the inner be recreated to refetch?
$this->inner->rewind();
}
function asArray() {
$this->fillTo(PHP_INT_MAX);
return $this->getCache();
@@ -1908,11 +1915,6 @@ function remove($object, $delete=true) {
$object->set($field, null);
}
function reset() {
$this->cache = array();
unset($this->resource);
}
/**
* Slight edit to the standard iteration method which will skip deleted
* items.
View
@@ -3373,11 +3373,9 @@ static function create($vars, &$errors, $origin, $autorespond=true,
// Save the (common) dynamic form
// Ensure we have a subject
$subject = $form->getAnswer('subject');
if ($subject && !$subject->getValue()) {
if ($topic) {
$form->setAnswer('subject', $topic->getFullName());
}
}
if ($subject && !$subject->getValue() && $topic)
$subject->setValue($topic->getFullName());
$form->setTicketId($ticket->getId());
$form->save();

0 comments on commit 74bdc02

Please sign in to comment.