General developer forum

Moodle moodleform::validation()

 
 
Tim at Lone Pine Koala Sanctuary
Re: Moodle moodleform::validation()
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

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.
 
Average of ratings: -
Picture of delta force
Re: Moodle moodleform::validation()
 

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.

 

 
Average of ratings: -
Picture of delta force
Re: Moodle moodleform::validation()
 

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?

 

 

 
Average of ratings: -