Forums

Use value from relation table

webcrea 13 Sep, 2016
hi,

I have 3 tables enrollments->sessions->cursus

I would want to use a value from cursus table named cursus_alias in a drop-down in a form for the enrollments
- Field name : enrollments[sessions_id]
- Id : sessions_id

in Dynamic data
- Data path : sessions
- value key : id
- text key : cursus.cursus_alias
(doesn't work with that)

in Setup I have a DB read sessions with relation to cursus

debug is
Array
(
    [option] => com_chronoconnectivity5
    [cont] => lists
    [ccname] => crmEnrollments
    [act] => edit
    [Itemid] => 1940
    [gcb] => 2
    [enrollments] => Array
        (
            [id] => 2
            [subscribers_subid] => 50063
            [sessions_id] => 3
            [cursus_alias] => FWS-ENG-2B (not this one, it's for the future)
            [enrollment_date_start] => 2016-05-18
            [enrollment_date_end] => 2016-06-24
            [enrollment_date_exam] => 2016-07-01
            [order_invoice_id] => 0
            [order_invoice_number] => 
            [provider_country] => 
            [provider_state] => 
            [manual_date_shipped] => 0000-00-00
            [manual_ship_tracking_number] => 
            [exam_score] => 0
            [exam_result] => 0
            [exam_result_date_mailed] => 0000-00-00
            [student_email] => 
            [student_first_name] => 
            [student_last_name] => 
            [student_address1] => 
            [student_address2] => 
            [student_zip] => 
            [student_town] => 
            [student_state] => 
            [student_country] => 
            [student_phone] => 
            [enrollment_comments] => 
        )

    [sessions] => Array
        (
            [id] => 
            [cursus_id] => 
            [session_date_start] => 
            [session_date_end] => 
            [session_date_exam] => 
        )

    [cursus] => Array
        (
            [id] => 
            [providers_id] => 
            [versions_id] => 
            [cursus_format] => 
            [cursus_alias] => 
        )

    [0] => Array
        (
            [sessions] => Array
                (
                    [id] => 8
                    [cursus_id] => 5
                )

            [cursus] => Array
                (
                    [cursus_alias] => WSG-USA/DL/FWS-ENG-5-2
                    [cursus_format] => DL
                )

        )

    [1] => Array
        (
            [sessions] => Array
                (
                    [id] => 9
                    [cursus_id] => 3
                )

            [cursus] => Array
                (
                    [cursus_alias] => ICS-VANCOUVER/CR/FWS-ENG-1
                    [cursus_format] => CR
                )

        )

    [2] => Array
        (
            [sessions] => Array
                (
                    [id] => 10
                    [cursus_id] => 2
                )

            [cursus] => Array
                (
                    [cursus_alias] => AWSEC-AUS/CR/FWS-ENG-5-2
                    [cursus_format] => CR
                )

        )

)

the connexion to chronoconnectivity seems to not work
webcrea 14 Sep, 2016
I succeded to have value in $form->data but i can't push itt in the dropdown, someone has an idea, please ?
Array
(
    [option] => com_chronoconnectivity5
    [cont] => lists
    [ccname] => crmEnrollments
    [act] => edit
    [Itemid] => 1940
    [gcb] => 2
    [enrollments] => Array
        (
            [id] => 2
            [subscribers_subid] => 50063
            [sessions_id] => 9
            [cursus_alias] => FWS-ENG-2B
            [enrollment_date_start] => 2016-05-18
            [enrollment_date_end] => 2016-06-24
            [enrollment_date_exam] => 2016-07-01
            [order_invoice_id] => 0
            [order_invoice_number] => 
            [provider_country] => 
            [provider_state] => 
            [manual_date_shipped] => 0000-00-00
            [manual_ship_tracking_number] => 
            [exam_score] => 0
            [exam_result] => 0
            [exam_result_date_mailed] => 0000-00-00
            [student_email] => 
            [student_first_name] => 
            [student_last_name] => 
            [student_address1] => 
            [student_address2] => 
            [student_zip] => 
            [student_town] => 
            [student_state] => 
            [student_country] => 
            [student_phone] => 
            [enrollment_comments] => 
        )

    [sessions] => Array
        (
            [id] => 9
            [cursus_id] => 3
            [session_date_start] => 2016-10-20
            [session_date_end] => 2016-11-05
            [session_date_exam] => 2016-11-15
        )

    [cursus] => Array
        (
            [id] => 3
            [providers_id] => 6
            [versions_id] => 9
            [cursus_format] => CR
            [cursus_alias] => ICS-VANCOUVER/CR/FWS-ENG-1
        )

    [0] => Array
        (
            [enrollments] => Array
                (
                    [id] => 1
                    [sessions_id] => 8
                )

        )

    [1] => Array
        (
            [enrollments] => Array
                (
                    [id] => 2
                    [sessions_id] => 9
                )

        )

    [2] => Array
        (
            [enrollments] => Array
                (
                    [id] => 3
                    [sessions_id] => 10
                )

        )

    [3] => Array
        (
            [sessions] => Array
                (
                    [id] => 8
                    [cursus_id] => 5
                )

            [cursus] => Array
                (
                    [id] => 5
                    [cursus_alias] => WSG-USA/DL/FWS-ENG-5-2
                )

        )

    [4] => Array
        (
            [sessions] => Array
                (
                    [id] => 9
                    [cursus_id] => 3
                )

            [cursus] => Array
                (
                    [id] => 3
                    [cursus_alias] => ICS-VANCOUVER/CR/FWS-ENG-1
                )

        )

    [5] => Array
        (
            [sessions] => Array
                (
                    [id] => 10
                    [cursus_id] => 2
                )

            [cursus] => Array
                (
                    [id] => 2
                    [cursus_alias] => AWSEC-AUS/CR/FWS-ENG-5-2
                )

        )

)
Max_admin 14 Sep, 2016
if your form field name matches the path to the value in the data array then it should load this data, in your case it should be "cursus[cursus_alias]"

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 14 Sep, 2016
Thanks for reply, i tried it but it doesn't work. the dropdown allways empty
I solved problem with a json but it should be better to use value from relation
GreyHead 14 Sep, 2016
Hi Christophe,

If you look at the data in the Debugger output you have several separate arrays with sub-arrays, There is something fundamentally wrong with the set up of the DB Read action. What exactly are the settings you are using there?

Bob
webcrea 20 Sep, 2016
Hello Bob,

Yes i understand but what I must to do, i changed many things now.
I have CC5
enrollments->sessions->cursus and in the same
cursus->providers
cursus->versions

each model had field model_id to link to model

in CF5 the form with several DB read but doesn't work well because i don't have the relation after 2 index
DB read enrollments with relation to sessions
DB read sessions with relation to cursus
..etc...
GreyHead 20 Sep, 2016
Hi Christophe,

There is something fundamentally wrong with the set up of the DB Read action. What exactly are the settings you are using there?

Bob
This topic is locked and no more replies can be posted.