7 users online. Create an account or sign in to join them.Users
send-email event and multiple recipients
This is an open discussion with 2 replies, filed under Troubleshooting.
Search
You need [] on the end of your field's name:
<select multiple="multiple" name="fields[recipients][]">
That will give you the array in the $_POST. But, the Event isn't going to listen to it as it expects comma separated usernames, not an array.
Thanks Alistair. I've added the []
It's not pretty but this works:
public function load(){
if(isset($_POST['action']['save-message'])){
if($_POST['fields'] && $_POST['fields']['recipients'])
$_POST['send-email']['recipient'] = join(',', $_POST['fields']['recipients']);
return $this->__trigger();
}
}
Create an account or sign in to comment.
I'm having some trouble with multiple recipients. I know that they're suppose to be comma separated but I thought I could do the following:
<label>Recipients</label> <p> <select multiple="multiple" name="fields[recipients]"> <option value="username1">Username 1</option> <option value="username2">Username 2</option> <option value="username3">Username 3</option> </select> </p>And have my hidden fields:
At the moment if I print out the $_POST, it shows that only one username is the value of the recipients -- even though I've selected more than one.
I know I could make the value have a comma separated variable with JavaScript, but I'm wondering if there's a Native way to do this.
Thanks.