This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello. I'm developing a simple survey plugin and I'm having a hard time getting nested relations to work in forms.
Models I have:
Survey
Question
QuestionChoice
Relationships I have:
- One
Survey
may have manyQuestions
. - One
Question
may have manyQuestionChoices
.
I have only one controller, which is called Surveys
. All these models should be managed from this controller! After creating a Survey
and switching to update
context user sees a Questions
field of type partial
, which is rendered via $this->relationRender('questions')
and is located in controllers/surveys/_questions.htm
. Next user should be able to click "Add Question" button and create a new Question
. But Question
form has a relation field called choices
, which should be rendered via partial too. I created this partial in controller/surveys/_choices.htm
. But now I get "Relation config doesn't have definition for 'choices'.". It seems like I have to add choices
relation to my relation_config.yaml of Surveys controller, like I did with questions
relation. But I didn't find any way to refer a nested relation from relation_config.yaml. I tried to call this relation question[choices]
and stuff but it didn't work. How can I define relation of relation in my relation_config.yaml or atleast force Questions
"sub form" to use Questions
controller instead of Surveys
?
Last updated
Or does it mean I can't use $this->relationRender
for any relations that have futher $this->relationRender
?
Last updated
Same problem here! Nested field of type partial
is not working. Any one there to help please?
Any of you guys able to get this working? I'm also struggling with this issue and nothing seems to work.
Would be nice if someone can help me out.
I think you should add choices
in questions
with backend relation config in questions
controller.
So controller/surveys/_choices.htm
should put in controller/questions/_choices.htm
davidlopez32180 said:
Same problem, solution please???
It seems that there is only one way. I tried to create formwidget, but it doesn't work yet. https://octobercms.com/support/article/ob-21
The only way to create multilevel relationships in the backend is still that way explained in the tutorial?
Last updated
1-9 of 9