I'm building a simple message system using Zend Form where users will be able to select multiple recipients. Each recipient may be a different user type and so I need to have both the user type and the ID to send to the servicelayer. The form will start off with one recipient selected (as an array element in the form), and I plan to use jQuery to append each subsequent recipient to said array. I wish to end up with this:
array(4) {
["Subject"] => string(4) "My message subject"
["Body"] => string(6) "My body of text"
["Recipients"] => array(1) {
[0]
["profile"] => string(2) "476"
}
[1]
["otherusertype"] => string(1) "54"
}
}
}
This would enable me to loop through each recipient nice and easily, gaining the user type and the respective ID.
Now, I am currently doing this in Zend Form:
$form->addElement(
'hidden',
$type,
array(
'value' => $id,
'belongsTo' => 'Recipients'
)
);
But this leaves me with
array(4) {
["Subject"] => string(4) "hfgh"
["Body"] => string(6) "fghfgh"
["Recipients"] => array(1) {
["profile"] => string(1) "1"
}
}
As you can see, if I add another recipient of usertype "profile" to the array, it will just be overwritten.
How am I able to get an extra dimension within this array?
Thanks in advance!