This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
devzone:giftbox:sequentialnrs [2012/11/30 15:03] Roel |
devzone:giftbox:sequentialnrs [2020/03/12 12:06] (current) |
||
---|---|---|---|
Line 2: | Line 2: | ||
In order to create a sequential (study-)number for each new respondent, you need to create you own respondent controller.\\ | In order to create a sequential (study-)number for each new respondent, you need to create you own respondent controller.\\ | ||
- | Please see the [[devzone:howto|howto]] page first, on how to do that.\\ | + | Please see the [[devzone:howto:start|howto]] page first, on how to do that.\\ |
In the code below, you will see three functions in this controller: | In the code below, you will see three functions in this controller: | ||
* beforeSave, which will check the respondent number just before saving it | * beforeSave, which will check the respondent number just before saving it | ||
- | * createModel, which uses the parent model and creates the new respondent number using an extra variable for organization id | + | * createModel, which uses the parent model and creates the new respondent number using an extra variable for organization id as default value (*). |
* getRespNr, which uses the organization ID, gets the latest respondent number for that organization and returns the next respondent number | * getRespNr, which uses the organization ID, gets the latest respondent number for that organization and returns the next respondent number | ||
. | . | ||
Line 87: | Line 87: | ||
</code> | </code> | ||
+ | |||
+ | (*) In a simalar way you can set defaults for other fields in the createModel function:\\ | ||
+ | <code php> | ||
+ | $model->set('gr2o_consent', 'default', 'Yes'); | ||
+ | </code> | ||
+ | or\\ | ||
+ | <code php> | ||
+ | $model->set('grs_gender', 'default', 'M'); | ||
+ | </code> | ||
+ | |||
+ |