moodle-local_institutions /edit_form.php

Language PHP Lines 77
MD5 Hash 25708d231c23cf2af76733a9e1e1cd15
Repository https://github.com/jacano1969/moodle-local_institutions.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

/**
 * Edit institution form
 * @copyright 2013 Bruno Sampaio
 */

defined('MOODLE_INTERNAL') || die;

require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/completionlib.php');

class institution_edit_form extends moodleform {
    protected $institution;
    protected $context;

    function definition() {
        global $USER, $CFG, $DB;

        $mform = $this->_form;

        $institution = $this->_customdata['institution']; // this contains the data of this form
        $context   = get_context_instance(CONTEXT_SYSTEM);

        $this->institution  = $institution;
        $this->context = $context;

		/// form definition with new course defaults
		//--------------------------------------------------------------------------------
        $mform->addElement('header','general', get_string('general', 'form'));

		//Fullname
        $mform->addElement('text', 'fullname', get_string('field-fullname', 'local_institutions'), 'maxlength="254" size="100"');
        $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
        $mform->setType('fullname', PARAM_MULTILANG);

		//Shortname
        $mform->addElement('text', 'shortname', get_string('field-shortname', 'local_institutions'), 'maxlength="9" size="10"');
        $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
        $mform->setType('shortname', PARAM_MULTILANG);

		//URL
        $mform->addElement('text', 'url', get_string('field-url', 'local_institutions'), 'maxlength="2082" size="100"');
        $mform->addRule('url', get_string('missingurl'), 'required', null, 'client');
        $mform->setType('url', PARAM_MULTILANG);

		//Icon
        $mform->addElement('text', 'icon', get_string('field-icon', 'local_institutions'), 'maxlength="2082" size="100"');
        $mform->addRule('icon', get_string('missingurl'), 'required', null, 'client');
        $mform->setType('icon', PARAM_MULTILANG);

		//Address
        $mform->addElement('text','address', get_string('field-address', 'local_institutions'),'maxlength="254"  size="100"');
        $mform->setType('address', PARAM_MULTILANG);

		//Phone
        $mform->addElement('text','phone', get_string('field-phone', 'local_institutions'),'maxlength="49"  size="20"');
        $mform->setType('phone', PARAM_RAW);

		//Description
        $mform->addElement('textarea','description', get_string('field-description', 'local_institutions'), 'wrap="virtual" rows="10" cols="100"');
        $mform->setType('description', PARAM_RAW);

		//--------------------------------------------------------------------------------
        $this->add_action_buttons();
		//--------------------------------------------------------------------------------
        
		$mform->addElement('hidden', 'id', null);
        $mform->setType('id', PARAM_INT);

		/// finally set the current form data
		//--------------------------------------------------------------------------------
        $this->set_data($institution);
	}
}
Back to Top