Select Collection Attribute - How to programatically set the selected value?
Permalink 1 user found helpful
Hi,
I am having some trouble with categorising pages.
I have set up a Collection Attribute, it is a Select type. I have added five Values to it and can use Page::getCurrentPage()->getAttribute('category'); in order to retrieve the current value.
I am having trouble with setting this value and cannot find anything on the internet to help me with this.
I have been using the Page::setAttribute('category', 'value') successfully elsewhere and figured if I send the Value's ID or Value through it would deal with it for me but this has not been the case unless I am missing a step?
If anybody has any experience with this and could point me in the right direction it would be massively appreciated!
Thanks.
I am having some trouble with categorising pages.
I have set up a Collection Attribute, it is a Select type. I have added five Values to it and can use Page::getCurrentPage()->getAttribute('category'); in order to retrieve the current value.
I am having trouble with setting this value and cannot find anything on the internet to help me with this.
I have been using the Page::setAttribute('category', 'value') successfully elsewhere and figured if I send the Value's ID or Value through it would deal with it for me but this has not been the case unless I am missing a step?
If anybody has any experience with this and could point me in the right direction it would be massively appreciated!
Thanks.
Hi Robert,
Thank you. I have tried this and have not been having any luck. It works perfectly fine if the page attribute is a type other than select, but when it is a select nothing seems to happen!
I have tried passing the ID of the select value as well as the value.
Is there a different way to do this or is it simply a case of I must be doing something wrong here?
Thank you. I have tried this and have not been having any luck. It works perfectly fine if the page attribute is a type other than select, but when it is a select nothing seems to happen!
I have tried passing the ID of the select value as well as the value.
Is there a different way to do this or is it simply a case of I must be doing something wrong here?
Scratch that, I must have been sending the wrong data. It works perfectly now. Thanks for the help!
I believe this should be;
Robert