Setting hidden fields in form (2.3.2)

Re: Setting hidden fields in form (2.3.2)

by Hubert Chathi -
Number of replies: 3

You can define classes and functions within another function (and when you do require_once a library file inside a function, that's essentially what you're doing), but they get defined in the global scope, and behave exactly like if they were defined outside of the function.  As Davo mentioned, unlike languages such as JavaScript, they do not have access to the function's variables.

In reply to Hubert Chathi

Re: Setting hidden fields in form (2.3.2)

by Richard Crawford -

Okay, I admit that I am very confused at this point, and I'm not sure I've explained the issue I'm having properly.

As I described, and as I showed in the source code, I'm trying to get five hidden fields to show up in my form. When the form is rendered and I check the page source code, however, this is what I see:

 

<input name="studentid" type="hidden" value="3" />
 <input name="courseidtype="hiddenvalue="7" />  

 

As you can see, only two of the hidden form elements even exist, even though the data have been set properly in those two elements. What's happening is that the other three hidden form elements are not even rendering into the form. So regardless of the data (which seem to be getting passed properly), how can I get these hidden form elements to show up on the page I'm building?


ETA: I've figured out what I was doing wrong and it was incredibly stupid. Thanks to all who were attempting to help out.

In reply to Richard Crawford

Re: Setting hidden fields in form (2.3.2)

by Diane Villemure -

Richard, please share what you were doing wrong. I'll be asked to do the same thing as you soon and I will likely stumble into "incredibly stupid" too.

In reply to Diane Villemure

Re: Setting hidden fields in form (2.3.2)

by Richard Crawford -

Diane,

I doubt that my situation will be of value to you. I actually have the form defined in a separate file, rather than in core Moodle code (though I do have the include line in the Moodle code). I was simply editing the wrong file.

Richard