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:
SurveyQuestionQuestionChoice
Relationships I have:
- One
Surveymay have manyQuestions. - One
Questionmay 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