participante_id is a field of the record that is being inserted. It is an autoincrement and the primary key of the table, so now I see why it's null. Anyway I tried adding this code:
if (is_null($fieldarray['participante_id'])){
$part = new participante;
$part->sql_select = 'participante_id';
$participante_id = $part->getData("catsalut='".$fieldarray['catsalut']."'");
}else{
$participante_id = $fieldarray['participante_id'];
}
to
function _cm_post_insertRecord($fieldarray)
{
require_once 'classes/entidad.class.inc';
$entidad = new entidad;
$entidad->sql_select = 'entidad_id';
$entidad_id = $entidad->getData("nombre='" .$_SESSION['role_id'] ."'");
require_once 'classes/part_ent_xref.class.inc';
$part_ent_xref = new part_ent_xref;
if (is_null($fieldarray['participante_id'])){
$part = new participante;
$part->sql_select = 'participante_id';
$participante_id = $part->getData("catsalut='".$fieldarray['catsalut']."'");
}else{
$participante_id = $fieldarray['participante_id'];
}
$insert_array['participante_id'] = $participante_id;
$insert_array['entidad_id'] = $entidad_id[0]['entidad_id'];
$insert_array = $part_ent_xref->insertOrUpdate($insert_array);
if ($part_ent_xref->errors){
$this->errors = $part_ent_xref->errors;
return $fieldarray;
}
return $fieldarray;
}
but I get a null value in $fieldarray['catsalut'], catsalut is a field of the record that is being added.
Your help is really apreciated.