Skip to content

Commit

Permalink
Merge pull request #102 from catalyst/101-make-fields-optional-based-…
Browse files Browse the repository at this point in the history
…on-existence

fix: removed fields no longer shown as inputs
  • Loading branch information
Peterburnett authored Sep 6, 2022
2 parents aa73d83 + c610753 commit 4b7911e
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions classes/form/enrolkey_profile_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,42 @@ public function definition() {
$mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
$mform->setType('url', core_user::get_property_type('url'));

$mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
$mform->setType('icq', core_user::get_property_type('icq'));
$mform->setForceLtr('icq');
$removedfields = [];
if (defined('core_user::REMOVED_FIELDS')) {
$removedfields = core_user::REMOVED_FIELDS;
}

// Fields that might not exist, such as in Totara 13+.
if (!isset($removedfields['icq'])) {
$mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
$mform->setType('icq', core_user::get_property_type('icq'));
$mform->setForceLtr('icq');
}

$mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
$mform->setType('skype', core_user::get_property_type('skype'));
$mform->setForceLtr('skype');

$mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
$mform->setType('aim', core_user::get_property_type('aim'));
$mform->setForceLtr('aim');
// Fields that might not exist, such as in Totara 13+.
if (!isset($removedfields['aim'])) {
$mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
$mform->setType('aim', core_user::get_property_type('aim'));
$mform->setForceLtr('aim');
}

$mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
$mform->setType('yahoo', core_user::get_property_type('yahoo'));
$mform->setForceLtr('yahoo');
// Fields that might not exist, such as in Totara 13+.
if (!isset($removedfields['yahoo'])) {
$mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
$mform->setType('yahoo', core_user::get_property_type('yahoo'));
$mform->setForceLtr('yahoo');
}

$mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
$mform->setType('msn', core_user::get_property_type('msn'));
$mform->setForceLtr('msn');
// Fields that might not exist, such as in Totara 13+.
if (!isset($removedfields['msn'])) {
$mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
$mform->setType('msn', core_user::get_property_type('msn'));
$mform->setForceLtr('msn');
}

$mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
$mform->setType('idnumber', core_user::get_property_type('idnumber'));
Expand Down

0 comments on commit 4b7911e

Please sign in to comment.