This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Chad
Chad

I'm developing a plugin for something along the lines of quizzes. There's a 'course' model that hasMany 'questions' and the 'questions' hasMany 'answers'. I'm able to build out the controller for the course model and adding questions to it just fine. Now I'm trying to add the ability to add answers to the questions relation and running into some trouble.

This is what I have:

  • A courses controller, where you can add/delete/whatever else courses in the backend
  • questions as a field with type partial in the course fields and a $this->relationRender('questions') rendering it
  • answers as a field with type partial in the question fields and a $this->relationRender('answers') partial in the courses controller

When I try to create or edit a question, I get this error:

Call to undefined method October\Rain\Database\QueryBuilder::answers()" on line 1992 of /october/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php

In addition to the error, the questions lightbox didnt render any of the forms in it and just showed me raw HTML. I was able to make the first error go away by adding a hasManyThrough relation between courses and answers (through questions), but then I started getting this error there instead:

Undefined variable: widget" on line 633 of /october/modules/backend/behaviors/RelationController.php

Once again with the HTML not rendering.

I'm thinking maybe I'm not going about this the right way. Is it even possible to have a relationRender() within one of those create/edit popups? Should I just make a separate controller for questions? And if I do, is there a way I can make that controller open up from the courses when a one clicks create or edit a question?

Thanks for the help. Let me know if any additional information is needed.

ak+octobercms7736
ak+octobercms7736

I'm having exactly the same problems... In my case, i'm having a model project which 'belongs To Many' locations. Am I doing something wrong or is the octobercms backend not yet complete?

daftspunky
daftspunky

If you publish your plugin on GitHub, it will be easier for others to help you.

deroccha
deroccha

I have the same issue is there any answer on this?

sergio10964
sergio10964

Hi Chad! I'd really love to see your progress as I just started a project with the same specs.

maxDubovsky
maxDubovsky

I also wonder if there is any progress on that ?

triasrahman
triasrahman

same problem. any solution for this?

maxDubovsky
maxDubovsky

I think I ran into the same problem some time ago and solve it writing my own widget to controll stuff I need. Model can be saved and updated very easy if you build a valid post form. In some cases using checkboxlist is not a solution at all as there can be thousands of records, in case of morthtomany for example. IMHO

triasrahman
triasrahman

maxDubovsky said:

I think I ran into the same problem some time ago and solve it writing my own widget to controll stuff I need. Model can be saved and updated very easy if you build a valid post form. In some cases using checkboxlist is not a solution at all as there can be thousands of records, in case of morthtomany for example. IMHO

Hi @maxDubovsky What's your own widget you use? I'm trying to use the repeater widget, but it's for jsonable field. I don't know it's a good idea or not.

maxDubovsky
maxDubovsky

I mean FormWidget. You can find information on how to use it.

1-10 of 10

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.