Forums

Passing Parameter to Form from Content page using plugin

MainsailSoftware 15 Jan, 2015
I have a sign-up form I have created that adds a user to an activity. The form uses two DB tables: one that identifies multiple activities and the other participants associated to a given activity. I would like to use this form with the Chronoforms Plugin on a content page for a specific activity, but need to pass the form the activity identifier so the correct activity gets associated with the added participant. I don't want to create separate forms if I can avoid it, and don't want the user to have to select the appropriate activity. I am using Chronoforms v4.0.6 and gradually converting to v5.0.4 on Joomla! 3.3.3.

Is there a way to pass the activity identifier using something like {chronoforms data:"activity=2"}ActivityForm{/chronoforms} as described in this forum thread http://www.chronoengine.com/forums/posts/f4/t88901/chronoforms-plugin-parameter-and-show-form-action-support.html?hilit=plugin+parameters?

If not, how would you suggest I address this requirement?
Max_admin 16 Jan, 2015
Hi MainsailSoftware,

Please try this with v5:

{chronoforms5}form_name&activity=XYZ{/chronoforms5}


Now a field named "activity" in your form should have the XYZ value set.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
MainsailSoftware 16 Jan, 2015
Thanks Max,

I tried

{chronoforms5}Activity&activity_id=XYZ{/chronoforms5}

and the following is what is seen using the Debug action.

Array
(
[Activity] =>
[amp;activity_id] => XYZ
)

It working, but not as I expected... Any suggestions?
MainsailSoftware 16 Jan, 2015
I also tried

{chronoforms5}Activity&activity_id=XYZ&member_name=Name{/chronoforms5}

and got

Array
(
[Activity] =>
[amp;activity_id] => XYZ
[amp;member_name] => Name
)
Max_admin 17 Jan, 2015
I think that your text editor in the article has replaced the "&" by "&", please disable the editor and fix this then save and retry!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
MainsailSoftware 17 Jan, 2015
Hummm...

I am using Chrome browser and the latest Joomla! admin JCE editor...

I will try looking into what exactly is being generated and get back to you.
MainsailSoftware 17 Jan, 2015
Looking at what the JCE editor is producing, you are exactly correct! If I Toggle the editor to show the generated html, I get...

<p>{chronoforms5}Activity&activity_id=XYZ{/chronoforms5}</p>

I had to save the article with the JCE editor in Toggled to the html view. If you toggle back, it changes back to &.

I tried my code with this article plugin reference and change my data reference from amp;activity_id to activity_id and it works perfectly.

This is an editor issue as you suggest, but I would think most Joomla! admins will use the built-in content editing tools.

Perhaps you might consider allowing other separators in addition to &, such as $ or ? or colon or semi-colon or comma?

For now I can keep this issue in mind and perform direct HTML editing of the plugin reference before saving.
Max_admin 19 Jan, 2015
Thanks, I added a fix for that!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 19 Jan, 2015
Answer
Hi MainSailSoftware,

As a workaround you can edit the /plugins/content/chronoforms5/chronoforms5.php file and try adding an extra line after line 34
$mainframe = \JFactory::getApplication();
$match = str_replace('&', '&', $match); // << add this line
parse_str($match, $params);

Bob
MainsailSoftware 19 Jan, 2015
First, I want to say how great you guys provide support for your product! I am really happy that I purchased Chronoforms!

Bob, I made the change you suggested and that fixed the DB Save issue, but after I changed the Article back so that the JCE editor once again produced <p>{chronoforms5}Activity&activity_id=XYZ{/chronoforms5}</p> in the saved HTML, another error appeared.

The form I created initially does a DB Read to make sure the participant has not already registered for the Activity. As part of the conditions for the DB Read I have this snippet of PHP code:

<?php return array( 'activity_id' => $form->data['activity_id']); ?>

The error that appears on the frontend is as follows:

Notice: Undefined index: activity_id in /hsphere/local/home/a965916/mbiyc.com/joomla/administrator/components/com_chronoforms5/chronoforms/actions/db_read/db_read.php(67) : eval()'d code on line 4

Debut show:

Array
(
[Activity] =>
[amp;activity_id] => XYZ
)

I have look at the code in the admin component indicated at line 67. I guess I could hack something there, but I am not so sure I would be correcting the code in the right location. If I go back to making sure the saved Article HTML does not convert & to &, everything works correctly.

So, it appears that a fix to some other location in the code maybe needed. I will leave it up to you two to tell me how to proceed.

Jim
MainsailSoftware 19 Jan, 2015
Sorry Guys.... Please ignore my previous 2 posts... The change you recommended worked fine.

Evidently, when I FileZilla'ed the new plugin code up to the server, it did not initially take... I assume a Caching issue.

I also modified your debug action to include pr($form->actions_config) so I can see what the action is getting...

Again, thanks to the both of you for a great job with support and the components you have developed!

Jim
Max_admin 19 Jan, 2015
Hi Jim,

Great, no problems!🙂

btw, no need to hack the debugger action, just use your code inside a "custom code" atcion:

<?php
pr($form);


Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
MainsailSoftware 19 Jan, 2015
Dah!... I should have thought of that! But I was in coding mode in my local NetBeans editor.

Thanks again... love working with you guys!

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