fabrikErrorMessage is empty when 2 forms with the same table are on the same page

Makulia

Member
I have created 2 forms with ajax validation. Each form points to the same table and has a different number of fields.

In this case, fabrikErrorMessage is empty. Only general form error is rendered.

How to fix error data returning in this case?
 
Last edited:
You can't have two forms from the same list on the same page, you'll run in to all kinds of unpredictable problems, because the DOM element ID's and names will be duplicated. The DOM structure in the form is based on the Fabrik element names, which are based on the tablename, so you'll have multiple tablename___foo on the same page.

-- hugh
 
Not sure what you mean. As I said, you can't do it. The only "solution" would be to spend a year rewriting Fabrik so we don't use tablename___elementname as the element and DOM naming convention, and for everyone who uses Fabrik to change every use of an element placeholder or name in their custom PHP and Javascript.

It might be possible to fix how the error messages get displayed, but I can absolutely guarantee you would run into other problems. HTML and Javascript just don't allow you to have multiple DOM elements with the same ID, if you do duplicate ID's the results are "undefined" (so for example a JavaScript statement which selects an ID will get two when it expects one), and we derive our DOM ID's from the Fabrik element names.

You'll have to rethink your application workflow so you aren't displaying the same form more than once on the same page. Depending on what you are doing, you might be able to embed one form in an iframe. You can embed a form in an iframe by appending &iframe=1&tmpl=component to the form's URL, and using that as the src for the iframe.

-- hugh
 
Hello, Hugh! Thank you for the detailed explanation. You are totally right about unique DOM ID mandatorily.
I have rethought this case and came up with a better solution. Idea is to create a new list and form and assign new elements for it so DOM elements will have unique ID's. Then disable submission for this form and add the PHP plugin to a form. In this plugin, we could use event - OnBeforeStore and execute our custom code wich inserts collected info from form inputs to the desired table in DB.

Benefits of this solutions are that we still can use fields validation and all form plugins. The only downside of it is that we would have a new table with a structure but without data in our DB.

Alter field types set to "no" is not allowing to create, for example, field element:
Code:
Warning
You can't add fields to this list

If I could create this fields without altering DB table, it would be just what I needed. Maybe it's even better to allow creating forms without DB connection for this purpose.

Here is php code example:
Code:
$name = $formModel->formData['form_test_20___name'];
$profile = new stdClass();
$profile->name = $name;
$result = JFactory::getDbo()->insertObject('forms_test_22', $profile);

What do you think of this solution? Maybe it will help another Fabrik users.
 
Yes, this feature works and new fields only are added to the DB table.

But my idea is to create form without linking it to a DB table and then create the desired number of elements for it. I only need form and group, but not list.

I know, that fields names would be ___name. Html 5 allows it though it doesn't look pretty.
If I could attach a "fake" table name to this form, then this problem should be gone.
 
Back
Top