Smarter way to get db_table_name in Form-Plugin [SOLVED]

manne-hoffmann

New Member
Hello there at FABRIK,
I am just starting to get into FABRIK and am currently trying to write some "all-purpose" PHP-form-plugins.

The idea is to use them in all forms of the application I am trying to build. In order to access and/or manipulate form-fields I must use the notation 'table name___element'. As my PHP-plugins are meant to run for many forms I need a way to dynamically get the table name of the current form.

Currently I use a rather weird way, because I did not (yet ?) find a smart object-property to get the current 'db_table_name'. If I dump out(print_r) the current objects I can actually see the property 'db_table_name' populated with the current table name, but this property is "nested" deep inside the "object-tree", so all of my current attempts to retrieve it have failed. Maybe it is not even accessible from outside??

In case there is really no way of getting this info in a smart way ... here's my current "weird" solution:

PLUGIN used at 'onBeforeProcess'
PHP:
$tmp_form_data_keys = array_keys($this->data);
$tmp_table_name = explode('___', $tmp_form_data_keys[0]);
$my_current_table = $tmp_table_name[0];

PLUGIN used at 'onLoad'
PHP:
$tmp_form_data_keys = array_keys($formModel->data);
$tmp_table_name = explode('___', $tmp_form_data_keys[0]);
$my_current_table = $tmp_table_name[0];

Looking forward to your answers :)

So long,
Manfred.
 
Hi hugh,
... it DOES :)

I have already searched the wiki before, but couldn't find a list of all available methods and properties for the diverse classes that fabric uses.
Did I not use the right search-terms or does such a list just not exist?

EDIT:
I had already found http://fabrikar.com/docs/packages/Fabrik.html but that looks rather like the documentation of FABRIK's core code, but not the classes a "user" interacts when using FABRIK .. right ??

Beside that I have actually found a way to get a list of all the methods of formModel by using this code in a PHP-form-plugin ...
PHP:
$my_class = get_class($formModel);
$my_methods = get_class_methods($my_class);

foreach ($my_methods as $method_name) {
    echo "$method_name<br />";
}
exit;

Thanks in advance,
Manfred.
 
Last edited:
Well, that's just a public method in the form model. Not specifically a "user" thing.

Fabrik isn't really aimed at developers, so we don't have a specific "user" API. There's a couple of methods we tell people about, like $formModel->updateFormData() and $formModel->getElementValue(). If you want / need to go beyond that and into the guts of Fabrik, you can dig around in the code and see what there is. :)

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

Thank you.

Members online

Back
Top