Kola Posted June 18, 2020 Share Posted June 18, 2020 (edited) I am a newbie in processwire. Apologies in advance if its a silly doubt. I have an AsmSelect field in my CMS which is "assigned_to". It is user reference field which assigns multiple user to the task. I want to save multiple users in this field in CMS using API. So far I am able to save one user at a time using following. $p->assigned_to = $u->level1; $p->save(); I have tried few different things but I am not able to save multiple users in AsmSelect. Please help. Thanks in advance Edited June 18, 2020 by Kola Link to comment Share on other sites More sharing options...
Kola Posted June 18, 2020 Author Share Posted June 18, 2020 I have tried below code..this also doesnt work. $p->of(false); $p->assigned_to = array($u->level1,$u->level2,$u->level3); $p->save('assigned_to'); $p->save(); Link to comment Share on other sites More sharing options...
Kola Posted June 18, 2020 Author Share Posted June 18, 2020 OK I got it working. foreach ($arr as $a) { $p->assigned_to->add($a); } didnt know add and remove methods work with AsmSelect Apologies, Link to comment Share on other sites More sharing options...
adrian Posted June 18, 2020 Share Posted June 18, 2020 @Kola - glad you figured it all out ? The key thing here is that it's not really the ASMSelect inputfield, but rather the Page Reference fieldtype that's behind it - because you have that set to store multiple values you need to use the add() method. Same would go for checkboxes etc. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now