Skip to content

Commit

Permalink
MDL-71171 customfield_text: ensure we set defaults properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Apr 23, 2021
1 parent e29b256 commit 5eb3d47
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions customfield/field/text/classes/field_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ public function config_form_definition(\MoodleQuickForm $mform) {

$mform->addElement('text', 'configdata[displaysize]', get_string('displaysize', 'customfield_text'), ['size' => 6]);
$mform->setType('configdata[displaysize]', PARAM_INT);
$mform->setDefault('configdata[displaysize]', 50);
if (!$this->get_configdata_property('displaysize')) {
$mform->setDefault('configdata[displaysize]', 50);
}
$mform->addRule('configdata[displaysize]', null, 'numeric', null, 'client');

$mform->addElement('text', 'configdata[maxlength]', get_string('maxlength', 'customfield_text'), ['size' => 6]);
$mform->setType('configdata[maxlength]', PARAM_INT);
$mform->setDefault('configdata[maxlength]', 1333);
if (!$this->get_configdata_property('maxlength')) {
$mform->setDefault('configdata[maxlength]', 1333);
}
$mform->addRule('configdata[maxlength]', null, 'numeric', null, 'client');

$mform->addElement('selectyesno', 'configdata[ispassword]', get_string('ispassword', 'customfield_text'));
Expand Down

0 comments on commit 5eb3d47

Please sign in to comment.