Guest User

Untitled

a guest
Oct 5th, 2016
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require_once('config.php');
  4. require_once($CFG->dirroot.'/lib/formslib.php');
  5.  
  6. class test_form extends moodleform {
  7.  
  8. function definition() {
  9.  
  10. $mform = $this->_form;
  11.  
  12. $labels = array('North', 'Est', 'South', 'West');
  13. $select = $mform->addElement('select', 'mselect_name', 'Choose one or more directions', $labels);
  14. $select->setMultiple(true);
  15.  
  16. $mform->addElement('text', 'text_name', 'Enter your name');
  17. $mform->setType('text_name', PARAM_RAW);
  18.  
  19. $mform->disabledIf('text_name', 'mselect_name[]', 'neq', array(2,3));
  20.  
  21. $this->add_action_buttons($cancel = true, $submitlabel=null);
  22. }
  23. }
  24.  
  25. // ===================
  26.  
  27. $PAGE->set_context(context_system::instance());
  28. $PAGE->set_url('/mselect_test.php');
  29. $PAGE->set_title('mselect_test');
  30.  
  31. $mform = new test_form(new moodle_url('/mselect_test.php'));
  32.  
  33. if ($mform->is_cancelled()) {
  34.  
  35. }
  36.  
  37. if ($data = $mform->get_data()) {
  38.  
  39. }
  40.  
  41. echo $OUTPUT->header();
  42. $mform->display();
  43. echo $OUTPUT->footer();
RAW Paste Data