This topic is locked

ALLOW MULTIPLE SELECTION

7/11/2019 2:21:25 AM
PHPRunner General questions
L
lpadilla author

In Add page, I have a control 'list page with search' and I use multiple selection,when I choose 1 or 2 elements ,it working,but when I choose 3 o more it no working!
Please help me! I use phprunner 10.2 (33322)
Try to see what the field contains using the $ value variable in the BeforeInsert event,when I choose 1 or 2 elements its fine,but when I choose more elements this variable is empty!

Sergey Kornilov admin 7/11/2019

Make sure that the field you set up as a Lookup wizard is a text field in the database. It looks like you are trying to save multiple values into a numeric field and this won't work of course.

L
lpadilla author 7/11/2019



Make sure that the field you set up as a Lookup wizard is a text field in the database. It looks like you are trying to save multiple values into a numeric field and this won't work of course.


Yes,It was the problem, but I need to save numeric ids, I changed the data type to varchar in the database, but I need to save int ids.
My code:
if ($values["CATP_ID"])

{
$arr = explode(",",$values["CATP_ID"]);
for ($i=0;$i<count($arr);$i++){

$strInsert = "INSERT INTO TBL_PRUEBA

(CATO_ID,OBJN_META,CATP_ID,OBJN_DOCUMENTO,OBJN_FECHA_CREACION,OBJN_RESPONSABLE) VALUES

(".$values['CATO_ID'].",'".$values["OBJN_META"]."',".$arr[$i].",'".$values['OBJN_DOCUMENTO']."','".$values['OBJN_FECHA_CREACION']."','".$values['OBJN_RESPONSABLE']."')";
db_exec($strInsert);

}
}

Sergey Kornilov admin 7/12/2019

CATP_ID in the main table must a text field. CATP_ID in PRUEBA_TBL can be a numeric field.
If the main table and PRUEBA_TBL are the same table then this is what you can do.

  1. Modify your SQL Query adding a temporary field i.e.

select ...,

'' as CATP_ID_TEMP

from TBL_PRUEBA


2. Setup CATP_ID_TEMP as a multiselect lookup wizard.
3. After your code in BEforeAdd event add the following:

unset($values["CATP_ID_TEMP"]);