Merge branch 'MDL-79705-402' of https://github.com/paulholden/moodle into MOODLE_402_STABLE

This commit is contained in:
Huong Nguyen
2023-10-18 09:37:05 +07:00
3 changed files with 5 additions and 16 deletions
@@ -180,9 +180,8 @@ class user_profile_fields {
->set_type($columntype)
->set_is_sortable($columntype !== column::TYPE_LONGTEXT)
->add_callback(static function($value, stdClass $row, profile_field_base $field): string {
// Special handling of checkboxes, we want to display their boolean state rather than the input element itself.
if (is_a($field, 'profile_field_checkbox')) {
return format::boolean_as_text($value);
if ($value === null) {
return '';
}
$field->data = $value;
@@ -240,7 +240,7 @@ class user_profile_fields_test extends core_reportbuilder_testcase {
[
'c0_firstname' => 'Admin',
'c1_data' => '',
'c2_data' => 'Not set',
'c2_data' => '',
'c3_data' => '',
'c4_data' => '',
'c5_data' => '',
+2 -12
View File
@@ -14,17 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'profilefield_checkbox', language 'en', branch 'MOODLE_20_STABLE'
*
* @package profilefield_checkbox
* @copyright 2008 onwards Shane Elliot {@link http://pukunui.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Class profile_field_checkbox
*
* @package profilefield_checkbox
* @copyright 2008 onwards Shane Elliot {@link http://pukunui.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -52,10 +45,7 @@ class profile_field_checkbox extends profile_field_base {
* @return string HTML.
*/
public function display_data() {
$options = new stdClass();
$options->para = false;
$checked = intval($this->data) === 1 ? 'checked="checked"' : '';
return '<input disabled="disabled" type="checkbox" name="'.$this->inputname.'" '.$checked.' />';
return $this->data ? get_string('yes') : get_string('no');
}
/**