ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Dynamic dropdown for JEvents

typomaniac 06 Aug, 2020
Hi forum,
In an old CF 4 instance I had a simple but flawlessly working solution for fetching entries in JEvents and choosing them in Chronoforms with dropdown:
http://bodega-peninsula.ch/index.php/anlaesse/year.listevents/2020/08/06/-

So far, so good. But I had to rebuild the shop completely on an actual Joomla and VirtueMart basis. For security reasons, I would like to use CF v7. But I can't bring to work the two code snippets I used in CF v4. There, I simply had this one in "Custom Element":

<?php
$current_day = JFactory::getDate('+0 seconds');
$current_day = $current_day->toUnix();
$options = array();
$db =& JFactory::getDBO();
$query = "
SELECT `dtstart`, `summary`
FROM `#__jevents_vevdetail`
WHERE `dtstart` > " . $current_day ."
ORDER BY `dtstart`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->summary}'>{$d->summary}</option>";
}
?>

And in the options field, I just had this:
<?php echo implode($options); ?>=<?php echo implode($options); ?>

Even when I don't use the opening and closing tags in the PHP section in CF v7, this won't work.

Thanks for any hint. Guess, I wasted a lot of time trying, because the solution will be fairly simple ;-)

Martin
Max_admin 08 Aug, 2020
in v7, add a PHP action and use the PHP code you have without the tags

change $data = $db->loadObjectList(); to return $db->loadAssocList();

In your dropdown advanced settings, enable "dynamic options", in the data sources, add {var:php_name}, where php_name is the name of the php action you have (you get this when you hover over the action name)

Lastly, in the "option data value" write {var:summary} in both fields!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
typomaniac 10 Aug, 2020
Thanks, Max!

I'll keep that for the final release of CF7. Actually, I had to switch back to CF6 because of the e-mail field issue described in another post. The recipient's address is always set back to default admin e-mail after saving.

So in CF 6, I added a dropdown containing {var:php7}
The action is - with your proposed modification:
$current_day = JFactory::getDate('+0 seconds');
$current_day = $current_day->toUnix();
$options = array();
$db =& JFactory::getDBO();
$query = "
SELECT `dtstart`, `summary`
FROM `#__jevents_vevdetail`
WHERE `dtstart` > " . $current_day ."
ORDER BY `dtstart`;
";
$db->setQuery($query);
return $db->loadAssocList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->summary}'>{$d->summary}</option>";
}

What I get in the front end, is a dropdown list containing "Array". What I would like to have, is just the upcoming events, as was the case in the CF4 version:
http://bodega-peninsula.ch/index.php/anlaesse/year.listevents/2020/08/10/-

Guess it has something to do with obsolete DB queries in the code above...
Could you have a look at this?

Thanks so much,

Martin
Max_admin 10 Aug, 2020
Yes, the same code will not work on v6

Please try that code on v7 and we can find a solution for the recipient issue, you may try to use the Email Action instead ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
typomaniac 10 Aug, 2020
Thanks, Max.

The dynamic dropdown works now in CF7: https://dev.bodega-peninsula.ch/index.php/anlaesse/test-cf7

But the issue with the mail address still persists: Neither in the CF7 main settings nor in the form settings, adding an address is possible. In the form settings, I just get this:
Bildschirmfoto_2020-08-10_um_09.50.22.png

which is quite strange, as I don't want to add a text field as a recipient's address ;-)

Do you need access to the back end to check the issue? I got this phenomenon not only on this instance, but I also got it on two other forms on other sites which I uninstalled in the meantime.

Martin
typomaniac 10 Aug, 2020
Addendum: seems, like e-mail addresses have to be followed by a comma. Even though it's just about one single address. Is that correct?

Addendum 2: the Reply E-Mail and Reply Name fields cannot be filled resp. saved, even with comma separation. All entries are deleted after saving. Also here: the selection of form fields is i.m.h.o. not really helpful.
Max_admin 10 Aug, 2020
Answer
Some dropdowns are editable, like the recipients or the reply ones, you can select an existing field OR type an address then press Enter, that will store the value you typed, you must press Enter after you enter a new value in a dropdown!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
typomaniac 10 Aug, 2020
...as easy as can be. But one has to know the trick 😉

Thanks Max, again for your patience. But please add this hint to the description under the dropdown.

Martin
Max_admin 11 Aug, 2020
I will try to solve this in a future update! 🙂
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com