This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi,
I tried to use the model relation system in form behaviour. In my case my model Registration has hasOne to relation to itself called partner and I want to have the partner field in my form (I use the form Behaviour) when edit my registration in the backend. It almost work because I have the list of other registration of my DB in the dropdown but my current partner is not selected. I suppose it doesn't catch the right keys. You can see here my fields yaml field : http://pastie.org/9840659 and my model definition : http://pastie.org/9840677. Maybe I didn't get what key and otherKey in the relation declaration.
Thanks for the great help,
Hi It is hard to debug this without seeing all the symptons and understanding what you are trying to achieve. Anyhow here are some thoughts.
You dont need to use otherKey in belongsTo relations. But this is not your problem I think.
You have defined scope filters in your model but you are not using them in the definition of your relations. Again probably not your problem but I just wanted to point that out in case you have misunderstood something.
So actually I cant see where your problem is. I would be happy to investigate further if there was anything else you could share.
Thanks for your feedback, To explain the context, I made event registration plugin just for learning purpose with a simple form component for front and a simple backend (list+form behaviour). When user subscribe from the front end form (plugin component) it can a extra registration (partner. For this I add a relationship to my registration model with it self (master / partner relationship). Everything is working appart from the relation dropdown in the edit form (backend). The symptom is that when edit an existing registration from backend the form display properly, the partner relation dropdown works, it saves the relation link when I save. But when I select a registration which has a partner the partner is not selected in the dropdown it's always the default value whatever if registration has or hasn't a partner.
Is there any test I can do to give you more infos ? Cheers
Last updated
I'll try to do a simpler version from scratch, with classic relation just to check if I did something wrong.
I did a simple a test from scratch. I created a plugin, models and controller using command line tools. I have two models Page and Article, Page has a "hasMany" relation with with Article and Article has a "belongsTo" with Page, I create two controller Page and Article defined the form and list fields everythings seems two work.
Here is my files : fields.yaml : http://pastie.org/9843060 article.php : http://pastie.org/9843059
The only issue is when Edit an article or a page which has a relation with the other (my-article-1 is linked to my-page-1) the relation field is not selected in both way. I'm not sure if it's linked but have a similar issue in the administrator page of the settings menu, when I link a administrator to a group, it is linked on DB but when edit this user again all checkboxes are unselected.
I work with PHP Version 5.5.18 on apache server and Mysql server 5.6.21. His there any test I can do ?
Cheers,
Last updated
What happens if you change the default country in backend settings? This uses a relation dropdown and works correctly for me.
Just for info I tried with the recordFinder field and it works, Does anyone find a way to reproduce the bug ?
Last updated
1-8 of 8