Hi,
i hope i can explain what i mean...
My Plugin has following edit_form.php
[code lang]
protected function specific_definition($mform) {
// Section header title according to language file.
$mform->addElement('header', 'config_header', get_string('blocksettings', 'block'));
$allusercourses = array();
$courses = enrol_get_my_courses();
foreach ($courses as $c) {
$allusercourses[] = $c->fullname;
}
$mform->addElement('select', 'config_cid', 'choose your course', $allusercourses);
$mform->setDefault('config_cid', 0);
[/code]
Problem:The user can choose a course he is enrolled in at the configuration page of the plugin.
When the user hit the "save changes" button the number of the choosed array element is saved.
The problem is, if the enrolled course list from the user is changing (maybe he is no longer in some courses), the saved number of the array element is then pointing to another array element, because the array of enrolled courses has changed.
It is a simple block plugin which is showing the coursename which the user has choosen in the configuration. But after the users enrolled course list has changed, there is a wrong coursename in the block, not the initially choosen one.
Question:
How can i save the course id when choosing coursename in the plugin configuration? I think the form will only store the array number and not the name or id of the course.
best regards
basti