Checkbox in profile fields

Checkbox in profile fields

by alfren enriquez -
Number of replies: 2

Greetings!

Is it possible to change the html code of the checkboxes in the profile page?

In our profile we created a custom fields consist of checkboxes and when I checked the profile page, it doesn't look very good.

Most of the html codes in the profile page are consist of:

<dd></dd> and <dt></dt>

Here's what our profile page looks like: http://screencast.com/t/A5NRCglDxfIf possible we want it to look like in the edit profile page: http://screencast.com/t/M8oK5eRWQbl

 

Many thanks!

Average of ratings: -
In reply to alfren enriquez

Re: Checkbox in profile fields

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Alfren,

The way Moodle displays checkboxes is very non-standard. Typically checkboxes should appear before the text, not after. I had to swap them around recently but did not find any way of doing this without modifying core Moodle code. So instead, I added the following JavaScript my theme:

<script>
$( document ).ready(function() {
// ******************************************************************
// Move checkboxes in front of text instead of after.
// ******************************************************************
$('.fitem_fcheckbox > div').each(function() {$(this).prependTo(this.parentNode);});
$(".fcheckbox").css('float','left');
$(".fcheckbox").css('margin','0 10px 0 13%');
$(".fcheckbox").css('width','auto');
$(".fitem_fcheckbox > div.fitemtitle").css('width','auto');
$(".fitem_fcheckbox > div.fitemtitle").css('text-align','left');
}
</script>

It assumes you have jQuery loaded. If you don't, you will ether have to load it or re-write this without it.

While it won't help you put your checkboxes in two columns, it will look better.

Keep in mind that changes you make to the presentation of checkboxes will likely affect other pages on your site besides the page you intended to fix. I was also doing it only for the User Profile page so I added a little PHP around this to conditionally have it apply only when the user or an administrator was editing a user profile. You can do this by checking the URL.

Hope this helps.

Best regards,

Michael Milette