Is it possible to return the lookup field 'id' rather than the 'name'?

Transistor

New member
I have a lookup table in my application similar to this:

[pre]
id | name
---+-----------------
0 | No progress
1 | In progress
2 | Complete
[/pre]

The form then uses a select_single_radio to display

( ) No progress ( ) In progress ( ) Complete

and the value 0, 1 or 2 is saved in the application table. This all works well.

Question:

Is it possible to display the 'id' value as well as the 'name' value in a report? When I use 'dadabik_field progress dadabik_field' the report shows the text of the lookup. How could I display the 'id' value in my PDF report?



DaDaBIK is 9.4-Monterosso
 

eugenio

Administrator
Staff member
Hello,
try to add the id as an additional "Lookup table linked fields" in form configurator.

Best,
 

Transistor

New member
Not quite right. The 'Lookup linked fields' is now set to 'name' and 'id'.

In the form ...

What I want:
( ) No progress ( ) In progress ( ) Complete
What I get:
( ) No progress 0 ( ) In progress 1 ( ) Complete 2

and in the report I

What I want:
2
What I get:
Complete 2

Maybe I have to create a different form for this. It complicates things a little.
 

eugenio

Administrator
Staff member
Hello,
the linked fields set impacted both on the PDF and on the form so if you want a different set of linked fields, this is not possible.
Maybe you can try using a formatting function (check if $pass_linked_fields_to_format_function_as_array is 1) and to format differently the values according to the context, something like

[pre]
if (isset($_GET['export_to_pdf']) && $_GET['export_to_pdf'] === 1){
..... format for pdf ....
}
else{
..... format for all the other cases ....
}
[/pre]

Best,
 

Transistor

New member
Thank you for your reply.

For now I created a different page for the PDF datagrid. This one selects the values and I use those in the PDF. All is OK for now.
 
Top