Form throws ' Parameter missing " error

Form throws ' Parameter missing " error

by Dan Baker -
Number of replies: 2

Hi I am struggling to pin down  a  bug in one of my  forms. 


It throws this  "Parameter missing " error:




parameter missing











When I check the stack trace   I can see  line  156 is part of an if else  statement. I see no issue  with the code itself : 

if ($id) {

    if (! $cm = get_coursemodule_from_id('tutorship', $id, 0, false, MUST_EXIST)) {

        print_error('invalidcoursemodule');

    }

    if (! $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)) {

        print_error('coursemisconf');

    }

    if (! $tutorship = $DB->get_record('tutorship', array('id' => $cm->instance), '*', MUST_EXIST)) {

        print_error('invalidcoursemodule');

    }

} else if ($t) {

    if (! $tutorship = $DB->get_record('tutorship', array('id' => $t), '*', MUST_EXIST)) {

        print_error('invalidcoursemodule');

    }

    if (! $course = $DB->get_record('course', array('id' => $tutorship->course), '*', MUST_EXIST)) {

        print_error('coursemisconf');

    }

    if (! $cm = get_coursemodule_from_instance('tutorship', $tutorship->id, $course->id, false, MUST_EXIST)) {

        print_error('invalidcoursemodule');

    }

} else {

    print_error('missingparameter');

}

Can  anyone shed  some more  light on this  issue.  Not sure  why it is dropping to the else as the other  parts  seem ok.

Average of ratings: -
In reply to Dan Baker

Re: Form throws ' Parameter missing " error

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Dan,

it looks like that none of the parameters "$id" or "$t" is submitted by your form.
You should check that in the form definition one of those parameters is defined as hidden input.

Best regards
Andreas

Average of ratings: Useful (1)
In reply to Andreas Grabs

Re: Form throws ' Parameter missing " error

by Dan Baker -
Thanks Andreas I will try and see why the form isn't doing that. Will let you know how that goes.