• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Form Module Pre-Filtering

joshurb

New Member
Hello,
I am trying to use the Form Module to display a form filled with information based off the current page the user is on. Is there a way to set the Row ID to look up a row based off a URL parameter ({customerid} for example)?

I turned on debug mode and it does not appear to convert the placeholder to the URL parameter in this module like it does in the list pre-filter screens. When I enter a row number instead of a placeholder in the row id field, the form populates with the expected data(but always that data since the number is hardcoded in). Is this possible or am I barking up the wrong tree?

Thanks

Josh
 
It's possible - but not literally...

Probably the easiest way is to:

1) Use the content plugin and display the form inside a Joomla article with something like:
Code:
{fabrik view=form id=3 rowid=[$my->myvar]}
2) Pass the variable in the URL to the article and then set in in some php code on the form load:
PHP:
$myVar = JFactory::getApplication()->input->get('myvar');
 
if (!is_null($myVar))
{
  $user = JFactory::getUser();
  $user->set('myvar', $myVar);
}

If that does not work (there are some issues with JS and the content plugins)... let us know and we can provide some more complex options that will use cookies or something and probably involve maintaining multiple copies of the List/Form, but will work with the raw form outside the content plugin. I tackled a similar issue detailed in this post which also has a code snippet to get the var from a cookie and then redirect to the form with it as the rowid...

Hope this helps,
Dale
 
Using the content plugin is correct but it can be done easier:
Create a custom HTML modul, text (X=your form id)

{fabrik view=form id=X rowid=[customid]}

Options: prepare content=yes
 
Thank you both for the quick reply. I think the custom HTML module is perfect for what I need to do.

I have inserted the {fabrik view=form id=X rowid=[customid]} in my custom HTML and my form is now showing up in the selected module position but some wires are getting crossed. I updated the embed statement to {fabrik view=form id=9 usekey=CRM_ID rowid=[id]}. The correct [id] is grabbed from the url and that number is used in the query to populate the form data but through debug, it looks like it is not using the usekey = CRM_ID and is querying against the rowid. What can I do to get it to query where CRM_ID=[id] instead of rowid=[id]?

It looks like you don't need the tablename___element name format in this case based off the wiki/content-plugin/#searching-for-form-records-to-edit . I tried it anyway and had the same result.

Thanks again
Josh
 
Should do.
Make sure that there are no additional blanks or HTML formatting inside {}.
Short element names are correct.
Enable fabrik debug in Fabrik Options/Debugging, then append &fabrikdebug=1 to your URL. "form: render" shows the generated query.
 
Thanks again for the very quick reply!

I double checked my {} and there are not any extra spaces or HTML between the brackets(that got me a couple of days ago). In the form:render the query is not using the key I am specifying in the content plugin statement with usekey=CRM_ID . It is still using the table's primary key. It seems like I am entering it correctly, So I am puzzled. Now what? lol.

Here is a copy and past of my statement, maybe there is something I am doing wrong or overlooking:
Code:
{fabrik view=form id=9 usekey=CRM_ID rowid=[id]}

Thanks again
Josh
 
Also just to be clear... you are asking to filter on CRM_ID=9 in your example.... is that what you are wanting?
 
Content plugin with filtering in module and article is both working on my site IF Joomla caching is OFF
(and "id" as parameter is not working if you are calling a J! article because here id is the article id, in a module it is working but better don't use it to avoid conflicts)

{fabrik view=form id=X rowid=[customid]}
{fabrik view=form id=X usekey=abc rowid=[customid]} (abc=short element name)
{fabrik view=list id=Y table___element=[customid]}

You can disable Joomla caching in general or you can disable Joomla caching for a single module in module settings.
 
I presume this discussion was prior to the Skype stuff where Troester seems to have confirmed that, for element filtering in a content plugin:

"It's alway the same: the filter is working if Joomla caching is OFF
or Joomla caching ON + user logged in"

?

-- hugh
 
Content plugin with filtering in module and article is both working on my site IF Joomla caching is OFF
(and "id" as parameter is not working if you are calling a J! article because here id is the article id, in a module it is working but better don't use it to avoid conflicts)

{fabrik view=form id=X rowid=[customid]}
{fabrik view=form id=X usekey=abc rowid=[customid]} (abc=short element name)
{fabrik view=list id=Y table___element=[customid]}

You can disable Joomla caching in general or you can disable Joomla caching for a single module in module settings.

Using the article ID instead of the fabrik id is my goal. I have have different data on the same list that I would like to filter depending on the article number.

I did turn off caching for this module and it seems to be bringing up the data by the wrong ID(non article ID) number still.

Thanks again everyone!
Josh
 
OK, so how would you relate the article ID to the table row?

The best way of doing this would be to store the article IDin the table, so you can do something like usekey=article_id rowid=[id], which should pick up the normal article &id=X from a standard com_content URL, and tell Fabrik to use your article_id field instead of the normal PK for the select.

The other way is to finagle it with some embedded PHP, which is what I usually do when I need to mess around with selections based on criteria which aren't easily done with a static plugin string, or grabbed from the query string.

That is to say, using something like Sourcerer, or Direct PHP, to embed some code in the article, which grabs the article ID, does whatever it needs to do to establish the filters it needs, then programatically builds and echoes out the {fabrik ...} string to use for the plugin.

But without knowing exactly what you need to do, and how you would establish the filter criteria from an article ID, I can really help.

-- hugh
 
Hmm. So, here is what I am trying to do:

I am using a customer management system and it displays a customer id in the url when you are on the page for a specific customer. I have a fabrik list of products that they have purchased. The primary key is a fabrik id/rowid. I also have the customer id as a field( I am now realizing that I am going to have to filter by 2 fields). Customer ID can appear several times since they can buy multiple products so for this reason, I think using the customer id as the primary key will not work.

My goal is to have the fabrik form show up an a module position( am using a custom html module) and auto populate with the filtered data from the {fabrik ....} string. I get the correct customer id when using [id] in that string(so I don't think I need to go the php route yet) but it is pulling up the wrong information because it is comparing the [id] with the primary key even though I use the usekey=CRM_ID. usekey=CRM_ID rowid=[id] should tell fabrik to filter by the CRM_ID field instead of the primary key field right?

So now, since I need to filter by 2 fields I will need to use usekey=CRM_ID|AnotherField rowid=[id]|anotherCriterion. I would be happy figuring out how to filter it off just the [id] though.

Thanks again
Josh
 
Well, usekey it won't tell us to "filter" by that field, it'll tell us to use that field as if it was the PK. In Fabrik, the term "filter" is very specific to iltering lists, not loading forms.

So where we would usually select the row for a form using "WHERE id = 123" for rowid=123 (assuming 'id' is your PK), we'll do "WHERE whatever = 123" (if you use usekey=whatever rowid=123). So 'whatever' has to be unique, as obviously the query for a form has to come up with a single row.

What I would do in this situation is manually work out the rowid I need, rather than trying to finagle Fabrik with multiple usekeys (which I don't think will work anyway).

So add some inline code that looks up your criteria directly in the table, so you resolve it to a single row. "SELECT id FROM yourtable WHERE foo = 123 AND bar = 234", or whatever the query is you need, to come up with the single row you need. Then use that id in a normal plugin string, without using usekey.

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

Thank you.

Members online

No members online now.
Back
Top