Nechalon - Hello, I have added a new module (co...
# ❓questions
n
Hello, I have added a new module (courseCategories) next to an existing module (courses), and now the routes are messed up for that existing module. I updated the twill-configuration and the links show correctly and redirect correctly. The problem happens when I try to edit an existing course on the courses page. (the page doesnt open)
Copy code
Route [admin.courses.mentors.browser] not defined. (View: /var/www/html/vendor/area17/twill/views/partials/form/_browser.blade.php)
i
What do you mean by next to? You nested them in the navigation? You'll need to specify their
routePrefix
in your browser fields
I assume your mentors module is not under courses in your navigation, it's at the root?
n
I mean that the courses module in the admin routes was "alone", and now its nested inside a group along with the new courseCategories module. I already specified it, to the same, to 'courses' and its still somehow throwing errors. Yes, mentors module is at the root, not nested
i
in that case your mentors browsers should specify an empty
routePrefix
the error is created by code in your repository class though
can you show me how you are saving/retrieving the mentors browser there?
n
you want to see the repository of courses?
Copy code
public function getFormFields($object)
    {
        $fields = parent::getFormFields($object);
        $fields['browsers']['mentors'] = $this->getFormFieldsForBrowser($object, 'mentors');
        $fields = $this->getFormFieldsForRepeater($object, $fields, 'terms', 'Term', 'terms');
        return $fields;
    }
hmm, and also getting an error when opening the main page of the twill admin panel
Copy code
Route [admin.courses.index] not defined.
i
getFormFields has a routePrefix parameter that you need to use
for the dashboard, you also need to specify routePrefix in your twill dashboard config
FYI routePrefix is not needed anymore in Twill 3
n
where would I put the routePrefix in the getFormFields function?
if you mean twill-config, thats already done and its working
okay, I fixed the browser issue, I had to add an empty routePrefix somehwere. Now I have this problem
Copy code
Route [admin.courses.edit] not defined.
I dont think there should be manually added edit function for the controller, becauses this is the twill form editor. Throws a route error
i
please share the context of that error, which file/method?
n
Its when trying to open up the homepage form, it has courses on it. There is no edit method for this controller, and it was working before
i
What I mean by context is the error stack trace
I can't help you debug if you give me half of the info needed to debug
the problem is still the same, you have a browser field with the wrong routePrefix
n

https://cdn.discordapp.com/attachments/1098928248932544602/1099984318622859345/image.png

i
your issue is in HomeRepository line 34
n
wow, im blind
Copy code
$fields = parent::getFormFields($object);

        $fields['browsers']['mentors'] = $this->getFormFieldsForBrowser($object, 'mentors');

        $fields['browsers']['courses'] = $this->getFormFieldsForBrowser($object, 'courses');

        $fields['browsers']['blogPosts'] = $this->getFormFieldsForBrowser($object, 'blogPosts', 'blogs');

        return $fields;
to me it looks like its setup correctly
the browser field is named 'courses'
*routePrefix
i
did you forget that your courses module is not at the root and for that reason you need to use the routePrefix parameter
n
it is courses.courses, should I put that in the repo and the routePrefix?
hmm, nothing, it should just be courses.
i
The routePrefix is the third parameter, it should be courses too
n
okay, solved it, had to add courses here
Copy code
$fields['browsers']['courses'] = $this->getFormFieldsForBrowser($object, 'courses', 'courses');
😄
in the
getFormFieldsForBrowser
function
i
It seems like you don't understand why though, it's not a coincidence and is what I keep telling you: https://twillcms.com/docs/api/2.x/A17/Twill/Repositories/Behaviors/HandleBrowsers.html#method_getFormFieldsForBrowser
if you move your modules into groups, you have to use the routePrefix parameter accordingly
n
I realized it, its because it wasnt grouped before, it was just
courses
, and now that I grouped it and added another module I had to change the routes, just didnt know where to
and what to change