mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-17048
Suppress display of empty custom profile field categories Merged from STABLE19
This commit is contained in:
parent
37ccf1fec9
commit
17a99a133e
1 changed files with 9 additions and 3 deletions
|
@ -72,7 +72,9 @@ class profile_field_base {
|
||||||
$this->edit_field_set_default($mform);
|
$this->edit_field_set_default($mform);
|
||||||
$this->edit_field_set_required($mform);
|
$this->edit_field_set_required($mform);
|
||||||
$this->edit_field_set_locked($mform);
|
$this->edit_field_set_locked($mform);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,13 +323,17 @@ function profile_definition(&$mform) {
|
||||||
if ($categories = $DB->get_records('user_info_category', null, 'sortorder ASC')) {
|
if ($categories = $DB->get_records('user_info_category', null, 'sortorder ASC')) {
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
if ($fields = $DB->get_records('user_info_field', array('categoryid'=>$category->id), 'sortorder ASC')) {
|
if ($fields = $DB->get_records('user_info_field', array('categoryid'=>$category->id), 'sortorder ASC')) {
|
||||||
$mform->addElement('header', 'category_'.$category->id, format_string($category->name));
|
$displayed = false;
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
|
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
|
||||||
$newfield = 'profile_field_'.$field->datatype;
|
$newfield = 'profile_field_'.$field->datatype;
|
||||||
$formfield = new $newfield($field->id);
|
$formfield = new $newfield($field->id);
|
||||||
$formfield->edit_field($mform);
|
if ($formfield->edit_field($mform)) {
|
||||||
|
$displayed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($displayed) {
|
||||||
|
$mform->addElement('header', 'category_'.$category->id, format_string($category->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue