Forums

How to send select from ChronoForm to ChronoConnectivity

orionstarman 04 Sep, 2010
Hello.

I have a Chronoform with a dynamic dropdown box and a submit button.
If I select a choice from the dropdown box , let's say I selected "3", how do I send that over to a ChronoConnectivity page that filter's the SQL with "3"?

I am pretty sure that a POST of a URL variable is involved but where do you assign it in Chronoform and then after in Chronconnectivity what do I call it in
Query Related Settings>WHERE SQL> WHERE "field_name" = ( what is the variable name sent from Chronoform? ).

And lastly how do configure my Chronoform to go to the designated ChronoConnectivity page when submitted?

I really appreciate any help.
Thank you in advance.
GreyHead 05 Sep, 2010
Hi orionstarman,

The 'usual' way to filter a ChronoConnectivity listing is to put the filter form in the Header box.

If you want to do it directly from a ChronoForm then either you need to set the action of the ChronoForm to the Listing and pick up the value from the Post variables; or, if you want the ChronoForm to do some processing, then build a ReDirect URL in the Form OnSubmit box and add the value. You'd then need to pick this up from the Get variables.

In either case you'd use the CC WHERE box to build the clause you need. If it's a Post variable this would look like
<?php
$some_var = JRequest::getVar('some_var', '', 'post');
echo "WHERE `some_column` = '$some_var' ";
?>


Bob
orionstarman 05 Sep, 2010
Hello Bob,

Thank you for your reply. Forgive me if I need a little clarification.

I am taking the route of letting the form do the work.
So at the form, if I wanted to pass a variable ( via post )named "fruit" and pass it to the URL "index.php?option=com_chronoconnectivity&connectionname=RockersRockers" , what would I do?

In Chronoforms:
I tried adding the URL to the form under the heading:
Form URLS
Redirect URL dialog box

And then in Chronoconnectivity I'm to add the code you provided under
Query Related Settings
Where SQL

is that right?

I do not know what you mean by CC WHERE.

P.S. I took a peek at your book. Looks REAL good , great , great info. I plan on getting it.
orionstarman 06 Sep, 2010
Oh I get the CC WHERE part. ChronoConnectivity . Still need to figure out what you meant on the rest.
GreyHead 06 Sep, 2010
Hi orionstarman,

You need to use the OnSubmit After Code box to build the URL and set it as the ChronoForms REDirect URL so that you will be sent there after the form has finished processing.

<?php
$fruit = JRequest::getString('fruit', '', 'post');
if ( $fruit ) {
    $url = 'index.php?option=com_chronoconnectivity&connectionname=RockersRockers&fruit='.$fruit;
    $MyForm->formrow->redirecturl = $url;
}
?>


Bob
orionstarman 06 Sep, 2010
Hello Bob , I got that redirecting thank you is this how it's supposed to look?
/index.php?option=com_chronoconnectivity&connectionname=EventList&fruit='.apple;
I see a "'" and an "." appended to the url when it goes to ChronoConnectivity as shown above.
Is that correct?

However the CC page shows no results. How do I get CC to take the value of 'apple' to filter the SQL?
I currently have this in the CC Where:
<?php
$fruit= JRequest::getVar('fruit', '', 'post');
echo "WHERE `produce` = '$fruit' ";
?>




Regards,

Orion
GreyHead 06 Sep, 2010
Hi orionstarman,

You have an extra '. in there that doesn't belong and will cause problems. The end result should be
. . . ctionname=EventList&fruit=apple;

Please check the quotes caefully in your code.

Bob
orionstarman 06 Sep, 2010
Thank you Bob. I think I got it.

I was using a redirect OnSubmit ( sending a variable appended to the URL )from CF to CC but trying to get the variable from CC using "POST". I realized I had to use "GET" to get the URL variable.
Woo-hoo.

But for those times I do not want to show the variables on the URL and use the POST method how do you do it with POST?
GreyHead 07 Sep, 2010
Hi orionstarman,

If you are going to have a separate "link" for each entry in a ChronoConnectivity listing then using the URL is by far the easiest way. I guess that it's possible to sue a submit button on each entry but probably that is too much work.

If you don't want to display info in the URL then you can 'encrypt' the data somehow and pass just a record id in the url then look up the data again in the form. There are several ways of doing this - you can 'encode' the parameter; you could save all the info in the User Session and look it up from there; you could look the info up in a database table.

The 'right' answere really depends on the way you are building the application - but most often adding a couple of variables to the URL is perfectly good.

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