Hi all:
I have a table where every user insert its own data, so the id field is hidden and the default value is set to CurrentUserId(). So far so good.
Now, I need another kind of users who can add its own data but other people data too, so this user can see the id field, and it shows a multiple select with other people id's.
In the row_inserting function, I explode the id field, and if it has more than a value, I do a foreach insert in the database.
The problem I've facing is if I just add one record for just one user, different than the one is logged, the id field is set to CurrentUserId(). I realize this so I deleted the default value for the field. But I still get the CurrentUserId() in my db.
Probably the problem is returning TRUE, but the $rsnew['user_id'] should be the form value, but it's CurrentUserId().
public function rowInserting($rsold, &$rsnew) {
$ArrayIds = explode(',', $rsnew['user_id']); //Comprobamos ahora si se está agregando más de un opoerario por un Jefe de Equipo
if (count($ArrayIds)>1){ //Inserting more than one user
foreach ($ArrayIds as $user){ // Loop through all the records
ExecuteStatement("INSERT INTO `mytable`(`user_id`, `date`,) VALUES ('" . $user . "','" . $rsnew['date']");
}
$this->setSuccessMessage($user_id. " added succesfuly");
} //foreach
} else { //adding just one user (MAYBE DIFFERENT FROM THE USER LOGGED IN)
}
return TRUE;
}
Thanks