mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-53071 course: Allow blank space input for section name
This commit is contained in:
parent
83a951023e
commit
eb66223c42
@ -38,10 +38,6 @@ class editsection_form extends moodleform {
|
||||
$mform->addGroup($elementgroup, 'name_group', get_string('sectionname'), ' ', false);
|
||||
$mform->addGroupRule('name_group', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255))));
|
||||
|
||||
// Add rule for name_group to make sure that the section name is not blank if 'Use default section name'
|
||||
// checkbox is unchecked.
|
||||
$mform->addRule('name_group', get_string('required'), 'required', null, 'client');
|
||||
|
||||
$mform->setDefault('usedefaultname', true);
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->disabledIf('name','usedefaultname','checked');
|
||||
@ -102,7 +98,7 @@ class editsection_form extends moodleform {
|
||||
$editoroptions = $this->_customdata['editoroptions'];
|
||||
$default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions,
|
||||
$editoroptions['context'], 'course', 'section', $default_values->id);
|
||||
$default_values->usedefaultname = (is_null($default_values->name));
|
||||
$default_values->usedefaultname = (strval($default_values->name) === '');
|
||||
parent::set_data($default_values);
|
||||
}
|
||||
|
||||
@ -116,8 +112,9 @@ class editsection_form extends moodleform {
|
||||
$data = parent::get_data();
|
||||
if ($data !== null) {
|
||||
$editoroptions = $this->_customdata['editoroptions'];
|
||||
// Set name as an empty string if use default section name is checked.
|
||||
if (!empty($data->usedefaultname)) {
|
||||
$data->name = null;
|
||||
$data->name = '';
|
||||
}
|
||||
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions,
|
||||
$editoroptions['context'], 'course', 'section', $data->id);
|
||||
@ -141,15 +138,6 @@ class editsection_form extends moodleform {
|
||||
\core_availability\frontend::report_validation_errors($data, $errors);
|
||||
}
|
||||
|
||||
// Validate section name if 'Use default section name' is unchecked.
|
||||
if (empty($data['usedefaultname'])) {
|
||||
// Make sure the trimmed value of section name is not empty.
|
||||
$trimmedname = trim($data['name']);
|
||||
if (empty($trimmedname)) {
|
||||
$errors['name_group'] = get_string('required');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user