Moodle

Formslib should let you pre-populate parts of a form with a GET request

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.8.7, 1.9.3
  • Fix Version/s: None
  • Component/s: Forms Library
  • Labels:
    None
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

At the moment, formslib is very strict about what data it submits. Each form has a mode 'get' or 'post' and depending on that, it will then read data just from $_GET or $_POST.

In comparison, required/optional_param will look for values first in $_POST, and if they are not found there, then it will look in $_GET.

The problem with formslib's behaviour is that it prevents you from directing users to a form, with a few fields pre-filled, using a simple link. (Which sometimes you want to do to create little mash-up things that save everyone time. See, for example, http://moodle.org/mod/forum/discuss.php?d=110648.)

My suggestion is that, even if a Moodle form is designated as a 'post' form. It should still take variables from $GET if they are not present in $_POST, and it should do that even if the sesskey=XXX and _qf_course_request_form=1 parameters are not in the request. However, if any variables are initialised this way, the form must not consider itself submitted.

Activity

Hide
Matt Gibson added a comment -

Yes, yes, yes! This is a big missing feature.

I've just spent half an hour messing about with a label on the front page, adding a 'Make new course' button using a small form and every time I save it, the hidden fields get stripped out by the blasted HTML editor. The only way to get it to work is by disabling javascript whilst editing.

Show
Matt Gibson added a comment - Yes, yes, yes! This is a big missing feature. I've just spent half an hour messing about with a label on the front page, adding a 'Make new course' button using a small form and every time I save it, the hidden fields get stripped out by the blasted HTML editor. The only way to get it to work is by disabling javascript whilst editing.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: