3.11 I added a user profile field. Some students, not all, will need to fill it in with their license number. The category name is visible, but it doesn't stay open so that the students can see where to fill in their license numbers. Part of the problem is the large description box above it, which is not needed at all.
How do I remove the description box on the profile page without impacting all of the other description boxes in the moodle, and how do I either move the new profile field into general near the top, or at least require the category to keep the choice visible?
There are no settings for this unless such functionality is a feature available in your theme's settings.
However, it is possible to hide any fields you do not want to display using CSS. To target the description field on specific pages, start your CSS selector with the body id for that page.
Best regards,
Michael
<legend class="ftoggler" id="yui_3_17_2_1_1640799357259_122"><a href="#" class="fheader" role="button" aria-controls="id_category_1" aria-expanded="false" id="yui_3_17_2_1_1640799357259_66">License Number</a></legend>
I am assuming that I need to change aria-expanded="false" to aria-expanded="true"
about line 93...
profile_signup_fields($mform);
ADD $mform->setExpanded('category_1');
This only affects Category id1 - this is the profile fields category. If other profile field categories are added, you will need to add to the array if they also require to be expanded by default.
Hi Cindy,
No need to apologize or modify any files. You can easily make additional profile field sections open by default by adding the following simple JavaScript to the Site Administration > Appearance > Additional HTML > Before Body is Closed field:
<script>
if (document.getElementById('page-login-signup')) {
document.getElementById('id_category_1').classList.remove("collapsed");
document.getElementById('id_category_1').classList.remove("collapsible");
}
</script>
Explanation:
- The if line just checks to make sure you are on the sign-up page.
- The line that ends with "collapsed"); will expand the collapsed section.
- The line that ends with "collapsible"); will remove the ability for the section to be collapsed again. This is optional but you did request a solution that will keep it open.
If you want to expand this on both the Sign-up page and the Edit Profile page, this can be accomplished with a slight modification to the line starting with if:
<script>
if (document.getElementById('page-login-signup') || document.getElementById('page-user-editadvanced')) {
document.getElementById('id_category_1').classList.remove("collapsed");
document.getElementById('id_category_1').classList.remove("collapsible");
}
</script>
If you have more than one section that you want to automatically expand, add more sets of both lines starting with document.getElementByID..., increasing the category number in each additiona set. Example:
<script>
document.getElementById('id_category_1').classList.remove("collapsed");
document.getElementById('id_category_1').classList.remove("collapsible");
document.getElementById('id_category_2').classList.remove("collapsed");
document.getElementById('id_category_2').classList.remove("collapsible");
</script>
By adding more JavaScript, you could even have it automatically do this for as many sections as there exists however I suspect this might be enough to meet your requirement and it gives you a little more control in case you don't want to expand all additional sections.
I tested this on Moodle 3.9 and 3.11 with the Boost, Classic, Trema, Moove and Adaptable themes and it seems to work. However, you may need to adapt it for other versions of Moodle and other themes.
Hope you find this helpful.
Best regards,
Michael Milette
For this task, I used the code to keep the box visible on both the sign-up page and edit profile.
My new profile field is now open and easy to find. Thank you!
Cindy
<script>
if (document.getElementById('page-login-signup') || document.getElementById('page-user-editadvanced')) {
document.getElementById('id_category_1').classList.remove("collapsed");
document.getElementById('id_category_1').classList.remove("collapsible");
document.getElementById('id_category_2').classList.remove("collapsed");
document.getElementById('id_category_2').classList.remove("collapsible");
}
</script>
Otherwise it would affect all pages.