Dynamic model events: Difference between revisions
From LimeSurvey Manual
DenisChenu (talk | contribs) m (Replace Token by Response since deleting token via GRID didn't launch this event) |
DenisChenu (talk | contribs) m (fix event name …⋅) |
||
Line 25: | Line 25: | ||
function init() | function init() | ||
{ | { | ||
$this->subscribe(' | $this->subscribe('afterResponseSave'); | ||
$this->subscribe(' | $this->subscribe('afterSurveyDynamicSave','afterResponseSave'); | ||
} | } | ||
Latest revision as of 09:18, 15 November 2018
Hint: This feature changed with version 3.5.1
Before LimeSurvey 3.5.1 version : only token dynamic event can be used like that.
When
Like Specific Model events.
Input
- model : The current model as a ActiveRecord
- dynamicId : if model extend Dynamic model ( ie Token and Response ). The related dynamic id
- surveyId and iSurveyID : The survey id if model is related to a survey id ( ie Token, TokenDynamic, Response, SurveyDynamic, Timing, SurveyTimingDynamic)
Possible output
None.
Example of usage
See AuditLog
function init()
{
$this->subscribe('afterResponseSave');
$this->subscribe('afterSurveyDynamicSave','afterResponseSave');
}
public function afterResponseSave()
{
$surveyId = $this->getEvent()->get('surveyId');
if (empty($surveyId)) {
// Something strange happen
} else {
// Log it somewhere
$oResponse = $this->getEvent()->get('model');
$this->log($oResponse->id." updated in survey".$surveyId);
}
}