Get Text Key and save in DB

fibernet 03 Feb, 2016
Hallo Bob, Hallo @all,

i have a small problem:

i have a multiplier field form and i want to get the "Text Key" from dropdown field to store in the dbase ( get later for pdf export).

Can you help me please?


The debuger output from dynamic loaded dropdown field values:


[ddata5] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [title] => Promotion
                )

            [1] => Array
                (
                    [id] => 2
                    [title] => Universität
                )

            [2] => Array
                (
                    [id] => 3
                    [title] => Fachhochschule
                )

            [3] => Array
                (
                    [id] => 4
                    [title] => Abgeschlossene Lehre
                )
.
.
.
.


The debugger info with the needed "title" field:


[edu] => Array
        (
            [0] => Array
                (
                    [user_id] => 398
                    [todate] => 09/1984
                    [institution] => 
                    [city] => Stuttgart
                    [subject] => worker
                    [qualification] => 3    <------stored value in profile database
                    [title] =>   <---------------needed title value
                )

        )


fibernet 03 Feb, 2016

[edu] => Array
        (
            [0] => Array
                (
                    [user_id] => 398
                    [todate] => 09/1984
                    [institution] => CFG
                    [city] => Stuttgart
                    [subject] => Instandhaltungsmechaniker
                    [qualification] => 3
                    [title] =>    <---------------needed title value (eg Fachhochschule)
                )

        )


fibernet 03 Feb, 2016
Debugger Info from DbRead Action:

[31] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `ddata5`.`id` AS `ddata5.id`, `ddata5`.`title` AS `ddata5.title` FROM `pnius_ddata5` AS `ddata5`
                        )

                )

        )
fibernet 03 Feb, 2016
And last the info from DbRead Action for the profile

[33] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `edu`.`user_id` AS `edu.user_id`, `edu`.`todate` AS `edu.todate`, `edu`.`institution` AS `edu.institution`, `edu`.`city` AS `edu.city`, `edu`.`subject` AS `edu.subject`, `edu`.`qualification` AS `edu.qualification`, `edu`.`title` AS `edu.title` FROM `pnius_edu` AS `edu` WHERE `edu`.`user_id` = '398' ORDER BY `edu`.`todate`
                        )

                )

        )
fibernet 04 Feb, 2016
Hi Bob,

i try this, but i think i am on the wrong way :-(

<?php

$title_array = array(
  1 => 'Promotion oder vergleichbare Zusatzausbildung',
  2 => 'Universität oder gleichwertiger Hochschulabschluss',
  3 => 'Fachhochschule/Akademie oder gleichwertiger Abschluss',
  4 => 'Abgeschlossene Lehre/Ausbildung',
  5 => 'Handelsschule oder vergleichbar',
  6 => 'Abitur oder gleichwertig',
  7 => 'Mittlere Reife oder gleichwertig',
  8 => 'Hauptschule oder gleichwertig',
  9 => 'Ohne Schulabschluss',
 10 => 'Andere'

);

foreach($form->data['edu'] as $k => $v ) {
$form->data['edu'][$k]['title']  = $title_array[$form->data['edu'][$k]['qualification']];
}

?>
GreyHead 04 Feb, 2016
Answer
1 Likes
Hi fibernet,

Please try
. . .
foreach($form->data['edu'] as $k => $v ) {
  $form->data['edu'][$k]['title']  = $title_array[$v['qualification']];
}
But I'm not sure exactly what you have in $form->data['edu']

Bob

[[>> updated <<]]
fibernet 04 Feb, 2016
Hi bob,

edu is a multiplier container and the second of five sliders.....i've appending a screenshot

the array data:

[edu] => Array
        (
            [0] => Array
                (
                    [user_id] => 398
                    [todate] => 09/1984
                    [institution] => testuniversity
                    [city] => new york
                    [subject] => engineer
                    [qualification] => 1    <----------value for title
                    [title] =>    <----------needed title
                )

        )
GreyHead 04 Feb, 2016
Hi fibernet,

Thank you - I updated the code in my last post.

Bob
fibernet 04 Feb, 2016
Hey Bob,

this was the solution 😀

I've try a lot of variations, this not 😶

Now I can finish my project, this was the last problem :mrgreen:

Thank you very much......
This topic is locked and no more replies can be posted.