How to handle custom fields in 3.7 child theme?

How to handle custom fields in 3.7 child theme?

by Renaat Debleu -
Number of replies: 5
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

How to handle custom fields when using a Boost or Classic child theme in 3.7? When running Behat, my child themes throw several general exceptions:

vendor/bin/behat --config behat/behat.yml --profile="firefox" --suite="testtheme"

001 Scenario: For the courses that existed before the custom field was created the default value is displayed
# customfield/field/textarea/tests/behat/default_value.feature:48
       And I log out
# customfield/field/textarea/tests/behat/default_value.feature:46
Moodle exception:  Exception - Class 'theme_testtheme\output\core\core_course\customfield\course_handler' not found
More information about this error
       ×
       Debug info:
       Error code: generalexceptionmessage
       (Exception)

Does anybody sees the same exceptions?

Average of ratings: -
In reply to Renaat Debleu

Re: How to handle custom fields in 3.7 child theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi, 

Sorry, but I know very little if anything at all about Behat, to be truthful, however I found this which may help you?

https://docs.moodle.org/dev/Running_acceptance_test

If nothing else you may find that some of the people who contributed to that document may have a better understanding of the problems you have encountered.

If no-one answers your questions here, it might be better to ask in the General Forum and at the same time add a link to this Forum post. That way you might get more people reading it and offering you advice!

Hope you found this helpful?

Cheers

Mary

In reply to Renaat Debleu

Re: How to handle custom fields in 3.7 child theme?

by john lennon -
Did you ever fix this? Same issue on my end.
In reply to john lennon

Re: How to handle custom fields in 3.7 child theme?

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
I fixed this (temporarly) by removing the use of customfields in my theme renderer.

When I talked about these errors with Bas Brands in the latest Moot in Barcelona, he could only advise me to raise a new issue in the tracker. Now that somebody else spotted the same behaviour, perhaps it is time to create a new tracker issue.
In reply to Renaat Debleu

Re: How to handle custom fields in 3.7 child theme?

by john lennon -
A new tracker issue ounds reasonable to me. I also fixed the issue by blatantly removing customfields from my theme renderer. Tried everything I could, but for some reason I can't call the customfield\course_handler, no matter what I try.
In reply to john lennon

Re: How to handle custom fields in 3.7 child theme?

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

No new tracker issue created because I found a solution modifying the course_renderer:

theme/my_theme/classes/output/core/course_renderer.php
++ use core_course\customfield\course_handler;
++ use core_customfield\data_controller;
++ use core_customfield\field_controller;

...

protected function coursecat_coursebox_content(\coursecat_helper $chelper, $course) {
...
// Display custom fields.
if ($course->has_custom_fields()) {
   -- $handler = core_course\customfield\course_handler::create();
++ $handler = \core_course\customfield\course_handler::create();
   $customfields = $handler->display_custom_fields_data($course->get_custom_fields());
   $content .= \html_writer::tag('div', $customfields, ['class' => 'customfields-container']);
}