Commit a74cd331 authored by Dan Poltawski's avatar Dan Poltawski
Browse files

MDL-39422 mod_forms: prevent long coruse module names

To prevent ugly DB errors.
parent 4fb3df32
......@@ -54,6 +54,7 @@ class mod_assign_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'assign'));
......
......@@ -45,6 +45,7 @@ class mod_assignment_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'assignment'));
......
......@@ -45,6 +45,7 @@ class mod_book_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro, get_string('moduleintro'));
$alloptions = book_get_numbering_types();
......
......@@ -22,6 +22,7 @@ class mod_chat_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('chatintro', 'chat'));
......
......@@ -22,6 +22,7 @@ class mod_choice_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('chatintro', 'chat'));
......
......@@ -22,6 +22,7 @@ class mod_data_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('intro', 'data'));
......
......@@ -44,6 +44,7 @@ class mod_feedback_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('name', 'feedback'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'feedback'));
......
......@@ -44,6 +44,7 @@ class mod_folder_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------
......
......@@ -22,6 +22,7 @@ class mod_glossary_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true);
......
......@@ -45,6 +45,7 @@ class mod_imscp_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------
......
......@@ -89,6 +89,7 @@ class mod_lesson_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Create a text box that can be enabled/disabled for lesson time limit
$timedgrp = array();
......
......@@ -67,6 +67,7 @@ class mod_lti_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields
$this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
$mform->setAdvanced('introeditor');
......
......@@ -47,6 +47,7 @@ class mod_page_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------
......
......@@ -69,6 +69,7 @@ class mod_quiz_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Introduction.
$this->add_intro_editor(false, get_string('introduction', 'quiz'));
......
......@@ -55,6 +55,7 @@ class mod_resource_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------
......
......@@ -43,6 +43,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Summary
$this->add_intro_editor(true);
......
......@@ -45,6 +45,7 @@ class mod_url_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------
......
......@@ -53,6 +53,7 @@ class mod_wiki_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('wikiname', 'wiki'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', $required, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields
$this->add_intro_editor(true, get_string('wikiintro', 'wiki'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment