Running a PHP Form Plugin after Tag Element creates new tags

Parisi

Member
I am running a very simple PHP form plugin on EndofFormSubmission. I use this plugin to take the ID of any tags that I have entered in a "tags" element and then echo out that information in the Joomla message area after clicking "save" on the form. The expected result is that the ID of any tags I have entered is echoed out in the message.

This works in all instances except if the tag I entered has not yet been created in the J tags table. In that case, the "message" on the next page echoes out "#fabrik#[newtag]" instead of an ID.

I suspect that the Fabrik Tag plugin runs its script to create any new tags after the "EndofFormSubmission", so that I am getting filler text instead of the newly created tag ID.

Is there any way I can run my script after the Fabrik Tag plugin creates a new tag?

Here is the code I am running:

Code:
// instantiate Joomla app
$app = JFactory::getApplication();
// get the array of information from the tag element
$add_tags = $formModel->getElementData('tag_form___add_tags');

// implode array of tag IDs into text
$add = implode(',',$add_tags);

// URL to navigate to after "save", currently home page
$your_url = "/";
// the imploded IDs
$your_msg = $add;

$app->redirect( JRoute::_($your_url), $your_msg);
 
I have attached a couple pictures to show results here.

Here is what happens when I enter a tag that already exists and click "save" (the tag was "duck" in this case), you can see that the tag ID is echoed out in the message:
Screen Shot 2016-10-07 at 2.27.50 PM.png
And here is the result when I enter a new tag in and click save (the tag was "deer" in this case):
Screen Shot 2016-10-07 at 2.28.39 PM.png
 
Instead of ...

Code:
$add_tags = $formModel->getElementData('tag_form___add_tags');

... try ...

Code:
$add_tags = $formModel->formDataWithTableName['tag_form___add_tags'];

The onAfterProcess hook does run after all the tag data has been written, but it updates a different data array to the one getElementData() uses.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top