diff --git a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php index c2c56110f..eaf8d409b 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php @@ -884,6 +884,9 @@ class ObjectFormManager extends FormManager // Ending transaction with a commit as everything was fine CMDBSource::Query('COMMIT'); + // Resetting caselog fields value, otherwise the value will stay in it after submit. + $this->oForm->ResetCaseLogFields(); + if ($bWasModified) { $aData['messages']['success'] += array('_main' => array(Dict::S('Brick:Portal:Object:Form:Message:Saved'))); diff --git a/datamodels/2.x/itop-portal-base/portal/web/js/portal_form_handler.js b/datamodels/2.x/itop-portal-base/portal/web/js/portal_form_handler.js index 139c91d01..91aeaefd7 100644 --- a/datamodels/2.x/itop-portal-base/portal/web/js/portal_form_handler.js +++ b/datamodels/2.x/itop-portal-base/portal/web/js/portal_form_handler.js @@ -135,16 +135,6 @@ $(function() // If everything is okay, we close the form and reload it. if(oValidation.valid) { - // Resetting textarea fields (delay is necessary has we have to wait for the form to be built. - setTimeout(function(){ - me.options.field_set.find('.portal_form_field_html').each(function(iIndex, oElem){ - if($(oElem).find('.cke').length > 0) - { - $(oElem).triggerHandler('set_current_value', ''); - } - }); - }, 200); - if(me.options.is_modal) { me.element.closest('.modal').modal('hide'); diff --git a/sources/form/form.class.inc.php b/sources/form/form.class.inc.php index 3687449ec..1e48a5902 100644 --- a/sources/form/form.class.inc.php +++ b/sources/form/form.class.inc.php @@ -19,10 +19,11 @@ namespace Combodo\iTop\Form; -use Combodo\iTop\Form\Field\SubFormField; use \Exception; use \Dict; use \Combodo\iTop\Form\Field\Field; +use \Combodo\iTop\Form\Field\CaseLogField; +use \Combodo\iTop\Form\Field\SubFormField; /** * Description of Form @@ -465,6 +466,28 @@ class Form return $ret; } + /** + * Resets CaseLog fields value in the form and its sub-forms + * + * @return Form + */ + public function ResetCaseLogFields() + { + foreach($this->GetFields() as $oField) + { + if($oField instanceof CaseLogField) + { + $oField->SetCurrentValue(null); + } + elseif($oField instanceof SubFormField) + { + $oField->GetForm()->ResetCaseLogFields(); + } + } + + return $this; + } + /** * Finalizes each field, following the dependencies so that a field can compute its value or other properties, * depending on other fields diff --git a/sources/form/formmanager.class.inc.php b/sources/form/formmanager.class.inc.php index 2bfbc3516..8a375c14d 100644 --- a/sources/form/formmanager.class.inc.php +++ b/sources/form/formmanager.class.inc.php @@ -29,7 +29,9 @@ use \Combodo\iTop\Renderer\FormRenderer; */ abstract class FormManager { + /** @var \Combodo\iTop\Form\Form $oForm */ protected $oForm; + /** @var \Combodo\iTop\Renderer\FormRenderer $oRenderer */ protected $oRenderer; /**