Moodle moodleform::validation()

Re: Moodle moodleform::validation()

by Tim Hunt -
Number of replies: 2
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodleform validates select inputs on the server-side, using the list of valid option values. (So you don't need $mform->setType). So, if you are only populating the select using Ajax, then that won't work.

There are various ways to do this:

  • Make a new formslib field type.
  • Hack the form definition code, so that if a value is selected in the first drop-down, then you populate the second drop-down with the correct values, etc.
In reply to Tim Hunt

Re: Moodle moodleform::validation()

by delta force -

Thanks for your response Tim. I got the reason why it was not working because i was creating blank county and city drop down on page load. So to fix it i simply displayed counties and cities for id 1 (one). This is just a little hack but it worked for me.

 

In reply to Tim Hunt

Re: Moodle moodleform::validation()

by delta force -

Hey Tim,

I actually overlooked. sorry for that... can you please instruct that how can i create a new formslib field type OR Hack the form definition code?