mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-8096 - some more fixes and minor refactoring in custom profile fields
This commit is contained in:
parent
1bf65e5880
commit
a5d3b07224
5 changed files with 28 additions and 32 deletions
|
@ -9,12 +9,12 @@ class profile_define_text extends profile_define_base {
|
|||
|
||||
/// Param 1 for text type is the size of the field
|
||||
$form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
|
||||
$form->setDefault('param1', 50);
|
||||
$form->setDefault('param1', 30);
|
||||
$form->setType('param1', PARAM_INT);
|
||||
|
||||
/// Param 2 for text type is the maxlength of the field
|
||||
$form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
|
||||
$form->setDefault('param2', 100);
|
||||
$form->setDefault('param2', 2048);
|
||||
$form->setType('param2', PARAM_INT);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
|
||||
class profile_field_text extends profile_field_base {
|
||||
|
||||
function display_field_add(&$form) {
|
||||
/// Param 1 for text type is the size of the field
|
||||
$size = (empty($this->field->param1)) ? '30' : $this->field->param1;
|
||||
|
||||
/// Param 2 for text type is the maxlength of the field
|
||||
$maxlength = (empty($this->field->param2)) ? '2048' : $this->field->param2;
|
||||
function display_field_add(&$mform) {
|
||||
$size = $this->field->param1;
|
||||
$maxlength = $this->field->param2;
|
||||
|
||||
/// Create the form field
|
||||
$form->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
|
||||
$form->setType($this->inputname, PARAM_MULTILANG);
|
||||
$mform->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
|
||||
$mform->setType($this->inputname, PARAM_MULTILANG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue