Edit course setting: Adding new fields (Two part question)

Edit course setting: Adding new fields (Two part question)

by Devin Monroe -
Number of replies: 0

Hello Moodle Community,

I am looking for a bit of guidance to see if something is possible because I seem to be running into issues with getting something very specific working that relates to me adding new fields to the "edit_form.php". I am doing this instead of a new plugin because of the user experience we are trying to create and this is too complex to go into the course format. This is technically two parts and two separate questions so I will explain them separately below.

First some info you may need:

I am on Moodle Version 4.0.1 installed on Debian GNU/Linux 10 (buster) which is running in a Docker container.
The fields are posting to a brand new DB table but the issue is not related to the DB directly.
The PHP version is PHP 7.4.12.

I think that is all that is relevant to the questions for now.

Question #1

I have added some new "searchableselector" fields to the form all of them allow multiple selections and I have been able to get the code ot process and save to the database and everything to return in the UI afterwards. The one thing that I am having a bit or trouble with is understanding how I might be able to add another field for each selection that is made.

For example I have 3 searchableselector fields that have multiple select for  each of the fields on each selection we want a new text input field where they can add a new data point that relates directly to the item selected.

The Items are built out via JavaScript and the Mustache templates. Is it possible to do this with Moodle already or will I have to find a way to override this?

Question #2

What's the best resource to learn things like this? I have been scouring the web, reading the Moodle Documentation that is available and now asking in the Forum but if I should be going about this a different way please let me know. There does not seem to be much out there on this stuff specifically but I understand that most people may not be trying to do what we are and maybe instead we should approach this with it's own plugin but for user experience we wanted it to happen right when they are setting the rest of the form settings.

Thanks in advance for any assistance or guidance anyone can provide.

Average of ratings: -