Value saved in field of table different of selected in dropdown menu

Value saved in field of table different of selected in dropdown menu

by Vitor Gonçalves -
Number of replies: 1

 For web output in a simple module, I use a dropdown menu box that list all activities/resources. The code is:

$lines = get_array_of_activities($course->id);
foreach ($lines as $line) {
    $line->mod = get_string("modulename", "$line->mod");
    $lo[] = $line->cm;
    //I prefer the line below:
    // $lo[] = $line->cm . ' - ' . $line->name . ' (' . $line->mod . ')';
    // resources or activities id-name and module name in course
}
choose_from_menu($lo, "resource", $form->resource);

But in the field "resource" of my table is saved 7 (value array) instead of 12 (label array -  $line->cm )...

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 6
    [4] => 4
    [5] => 5
    [6] => 7
    [7] => 12
    [8] => 13
    [9] => 15
)

What I have to do? Thanks

Attachment dropdownmenu.JPG
Average of ratings: -
In reply to Vitor Gonçalves

Re: Value saved in field of table different of selected in dropdown menu

by Vitor Gonçalves -

Problem solved:

   foreach ($lines as $key => $line) {
   $lo[$key] = $line->cm;
   }

Thanks anyway