How to get value of $cm->id for redirection in instantiated mform when pressing cancel button

How to get value of $cm->id for redirection in instantiated mform when pressing cancel button

by Simon Schaudt -
Number of replies: 0

Dear all,

I have recently started with moodle plugin development and was wondering whether someone could give me a hint or direct me to some documentation what I am missing. I have already read many of the moodledev.io pages and forum entrys including the API guide to Forms (https://moodledev.io/docs/apis/subsystems/form#usage).

At the moment I am at the point of having created a basic activity. I would like to have an extra form and cancelling that form does not work as expected. When cancelling the form I would like to return to my activity's view.php. What I already found out is:

  • After instantiating the form with $mform = new edittextelement(); var_dump($cm->id) returns my id (in this case string(3) "277").
  • When dumping after if ($mform->is_cancelled()) it does not dump anything.

I would appreciate if someone could help me with this.

Kind regards

Simon

Average of ratings: -