MDL-20203 Added support for disabled attribute for inputs and select options
[moodle.git] / blog / edit_form.php
CommitLineData
f07b9627 1<?php // $Id$
2
3require_once($CFG->libdir.'/formslib.php');
4
5class blog_edit_form extends moodleform {
6
2ee60b49 7 function definition() {
2ee60b49 8 global $CFG, $COURSE, $USER;
45df7de3 9
2ee60b49 10 $mform =& $this->_form;
f07b9627 11
2ee60b49 12 $post = $this->_customdata['existing'];
f07b9627 13 $sitecontext = $this->_customdata['sitecontext'];
14
f07b9627 15 $mform->addElement('header', 'general', get_string('general', 'form'));
2ee60b49 16 $mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"');
17 $mform->setType('subject', PARAM_TEXT);
18 $mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client');
f07b9627 19
2ee60b49 20 $mform->addElement('htmleditor', 'summary', get_string('entrybody', 'blog'), array('rows'=>25));
21 $mform->setType('summary', PARAM_RAW);
22 $mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client');
16851b22 23 $mform->setHelpButton('summary', array('writing', 'richtext2'), false, 'editorhelpbutton');
f07b9627 24
25 $mform->addElement('format', 'format', get_string('format'));
26
27 $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
28
29 $mform->addElement('select', 'publishstate', get_string('publishto', 'blog'), blog_applicable_publish_states());
d4175332 30 $mform->setHelpButton('publishstate', array('publish_state', get_string('publishto', 'blog'), 'blog'));
f07b9627 31
93bbdd50 32
33 if (!empty($CFG->usetags)) {
3d535996 34 $mform->addElement('header', 'tagshdr', get_string('tags', 'tag'));
fc23301c 35 $mform->addElement('tags', 'tags', get_string('tags'));
f07b9627 36 }
fc23301c 37
f07b9627 38 $this->add_action_buttons();
39
40 $mform->addElement('hidden', 'action');
2ee60b49 41 $mform->setType('action', PARAM_ACTION);
42 $mform->setDefault('action', '');
43
44 $mform->addElement('hidden', 'courseid');
45 $mform->setType('courseid', PARAM_INT);
46
47 $mform->addElement('hidden', 'id');
48 $mform->setType('id', PARAM_INT);
49 $mform->setDefault('id', 0);
50
51 }
52
53 /**
54 * This function sets up options of otag select element. This is called from definition and also
55 * after adding new official tags with the add tag button.
56 *
57 */
58 function otags_select_setup(){
47a2c30b 59 global $DB;
45df7de3 60
2ee60b49 61 $mform =& $this->_form;
bd1f4559 62 if ($otagsselect =& $mform->getElement('otags')) {
63 $otagsselect->removeOptions();
64 }
4c7fa6ce 65 $namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
47a2c30b 66 if ($otags = $DB->get_records_sql_menu("SELECT id, $namefield FROM {tag} WHERE tagtype='official' ORDER by $namefield ASC")) {
f07b9627 67 $otagsselect->loadArray($otags);
68 }
47a2c30b 69
2ee60b49 70 }
f07b9627 71
72}
73?>