How do I save element names without LIst name?

madpad

Member
I have a Fabrik List (List1) with several elements key,txnid,amount,productinfo, firstname, email, udf1, udf2...udf10. I also have a php form plugin that is triggered when the form is saved, and the database is then updated.

The problem I am having is that the data that gets saved in the payment gateway server is for elements in fabrik terminology {List1___key}, {List1___txnid}.....{List1___udf10}

But what they need is element names without the Listname, that is, key (instead of {List1___key}) etc...How do I eliminate the Listname from the element name?

Am on Joomla 3.4.0 and the latest Fabrik from Github.

Given below is that part of the php code if it helps. Thanks in advance.

---------
.....
$hash = '';
// Hash Sequence
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
if(
empty($posted['key'])
|| empty($posted['txnid'])
|| empty($posted['amount'])
|| empty($posted['firstname'])
|| empty($posted['email'])
|| empty($posted['phone'])
|| empty($posted['productinfo'])
|| empty($posted['surl'])
|| empty($posted['furl'])
 
See the 3rd example in the 'Examples' section on this Wiki page.
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/
PHP:
$formModel->_data; // for getTopContent, getBottomContent, getEndContent - use full element names: 'table___element'
Fabrik 3.0:
$formModel->_formData // onBeforeStore: use full element names 'table___element'
      //for onAfterProcess - use short element names: 'element' - no table name
Fabrik 3.1:
$formModel->data //onload: use full element names 'table___element' e.g. $formModel->data['table___element']='abc';
$formModel->formData // onBeforeStore: use full element names 'table___element'
      //for onAfterProcess - use short element names: 'element' - no table name (has issues with joined tables with identical column names (Jan. 2015)
Fabrik 3.2 onBeforeCalculation, onAfterProcess (Jan 2015)
$data['table___element']
 
// All versions of Fabrik also have a $formModel->fullFormData, which will contain the data keyed by full name, even onAfterProcess.
If, in the php form plugin, you put your php code in 'onAfterProcess' it will be already be using just the element name. Just be sure to use the correct syntax depending on which version of fabrik you are using.

Another option, that would be a universal fix - whether using fabrik or otherwise - would be to use the php substr and strpos functions to get just the element names.
e.g.
if $eName == 'your_table_name___your_element_name'
then substr( $eName, strpos($eName,'___')+3 ) would return just the 'your_element_name' part of the string.

Of course, that will only work if the table name itself does not contain a triple underscore ( '___' ).
 
Thanks Bauer.
I am using Fabrik 3.3, but then OnAfterProcess is certainly saving the List name and element name, together, not just element name.

If I use the php substr and strpos functions, should this be part of the same php file that I am using in Fabrik form processing? The +3 in the substr( $eName, strpos($eName,'___')+3 ) is for all elements?
Thanks a bunch.
 
To answer your questions - yes, to both.
But you'll need to better clarify just what you are trying to do before anyone can help you.
What do you mean by "the data that gets saved in the payment gateway server"?
Are you using the Paypal plugin? What is the "payment gateway"?
From the sample code that you posted it looks like you are using the $_POST data, which will always contain the list name as part of the key. Where/how do you come up with the $posted array???
Are you trying to get the element labels, element name, and/or element values - or all 3???
If you can better explain all that - and post the code you are using in the php form plugin - maybe I can help.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top