Forums

Read result

webcrea 17 Sep, 2015
Hello,

From an action DB read, in 'On found' I try to read result title
Array
(
    [chronoform] => Reserver
    [event] => submit
    [iditemk2] => 64
    [Nom] => hou
    [Prenom] => 
    [ville] => 
    [Pays] => 
    [Email] => chris@domain.com
    [Demande] => mjklh
    [newsletter] => 1
    [cdv] => 1
    [button7] => Envoyer
    [view] => item
    [Data3] => Array
        (
           [title] => WE Golf pour deux au Golf de Begard (Bretagne)
        )

)

thanks
GreyHead 17 Sep, 2015
Hi Christophe,

And what is the problem?

Bob
webcrea 18 Sep, 2015
Hello Bob,

Just I would retreive the variable [title] from the array. I try
$data=>Data3['title']
$Data=>Data3->title
$raw->
...etc

I know ;-)
regards
chris
ps : could you delete my email from the first post, please ?
GreyHead 18 Sep, 2015
Hi Christophe,

The simplest way is to leave the Model ID empty in the DB Read action - it doesn't look as though you need it.

Otherwise put {Data3.title} in the Email template assuming that is where you want it.

Bob
webcrea 18 Sep, 2015
Nice
Thanks Bob
Chris
webcrea 18 Sep, 2015
So I need the email of the partner to send him the booking. How can I do to use the field from the mysql request, please?
Regards
GreyHead 18 Sep, 2015
Hi Chris,

I assume that this is a ChronoForms question? (It's in the ChronoConnectivity forum.)

What field from the DB Read - the only data you are reading so far is a title?

Bob
webcrea 18 Sep, 2015
Yes it's chronoconnectivity, sorry for the mystaken category, could you change it?

and I added the email field in the request..
webcrea 18 Sep, 2015
... and it's a bit more complex because the field is a K2 extra_fields 😉
GreyHead 18 Sep, 2015
Hi Christophe,

Errrrrr is this ChronoForms or ChronoConnectivity?

What email field do you have in what request and where does K2 come into it??

That is to say, I have no idea what your question is :-(

Bob
webcrea 18 Sep, 2015
lol
it's chronoform,
a booking form for partner's offers. each offers are in K2 items, one offer by item
The form is call with loadmodule in each k2 item. I pass the k2 id of the item. the k2 item has some extra_fields like price, description, date from to and an email
this partner's email is use to send the booking
Is it more clear ?
GreyHead 19 Sep, 2015
Hi Christophe,

If you have the K2 item-id then you can use a DB Read action to get the information from the K2 tables (or a Custom Code action with a MySQL query included if it is a complex query to more than one table).

Bob
webcrea 20 Sep, 2015
hello bob,

this is what i do, a DB read action, and now, i would want, use the result in php to parse the field and use it.

my issue is what can i do to get the value ?

thanks
GreyHead 20 Sep, 2015
Hi Christophe,

The results of the DB Read are added to the $form->data array. If you set a Model ID they will be in a sub-array with the same name.

You can use them like any other CF (or PHP) variable.

To see exactly what is there add a Debugger action to the event after the DB Read action - you can delete or disable it when you are finished developing.

Bob
webcrea 21 Sep, 2015
Hello bob,

I find the data and i try this in a custom code Action :

<?php
$m = json_decode($form->data['Data3']['extra_fields']);
foreach($m as $e){
if($e["id"] == "18"){
$v = $e["value"];
define('E_PART' , $v) ;
}
}

?>

Fatal error: Cannot use object of type stdClass as array in /home/golfrendor/www/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 7

do you have an idea ?
webcrea 21 Sep, 2015
I solved the error by $m = json_decode($form->data['Data3']['extra_fields'], true);
webcrea 21 Sep, 2015
Bob,

Now i can retreive the email of the partner. It's in a define field define('E_PART', 'the_email');
and i would want to put it in the email to field of my send mail action.

do you have an idea to do this, please ?

regards
GreyHead 21 Sep, 2015
Hi Christophe,

You need to have it in the $form->data[''] array to use in the Email - I assume that is where you are getting it from to set the define statement?

If you have $form->data['the_email'] then you can use the_email in the Dynamic To box of the Email action.

Bob
webcrea 21 Sep, 2015
Nice, i forced $form->data['the_email'] in the stack and the life is beautifull

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