• 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.

Showing or Hiding a Field Based on Dropdown Choice of another Field

Stranger

New Member
What I want to do is simple. Based on the choice made on a dropdown field (e.g., country: 1. USA or 2.Canada)
I would like to show the relevant address field (zip code for USA or postal code for Canada) and hide the irrelevant one. I researched old posts and I think the following post is the closest match to my need:

http://fabrikar.com/forums/index.ph...eld-elements-based-on-parent-selection.43461/

If I understand correctly, I will have to go to the Country field, navigate to options, and then add JS code to do that. The difference from the post above, however, is that I do not need to create a separate group within the form. I also do not know much JS, unfortunately. So if anybody can help with adapting the solution above to my simpler situation and with the JS code, I will be grateful.

Thanks in advance.
 
Thank you. In principle that should probably work. However, when doing this I am getting error 500 alter structure: Duplicate column name 'country'. I think the problem is that when Fabrik generates the JS code based on the predefined JS actions it is not appending the table name to the column name (e.g., table_name.country) and SQL is at a loss as to which table the column 'country' belongs. Does anybody know of a way to fix this?
 
When do you get that error? It says "alter structure", which should only happen when you make changes on the backend that involve changing the database structure itself (like changing an element name or type, that involves making a change to the table structure itself).

-- hugh
 
From what I understand this is a common error that people get when upgrading to a new Joomla! version. What is recommended in this case is using the database Fix tool which I did, yet the error persists.

I have not knowingly altered my database tables in any way, save for adding a Fabrik element or changing the order of elements.
 
Excuse me. I focused on the latter part of your post. I get this error when going to the JavaScript of my element and trying to save a predefined action, which in this case is: upon event "select" show the field "zip_code" which is defined as hidden by default. When I click "save and exit" I get this error and of course the action is not saved.
I hope this answers your question.
 
Yup, it does.

Do you get the same problem if you make any other changes to the element?

I can't think of anything that setting a JS action does that could cause any confusion about field naming.

The only time I've seen anything weird happen with setting JS actions is when setting a lot of actions, and the number of HTML form elements being posted exceeds PHP's configured maximum.

-- hugh
 
Thank you Hugh. I never actually thought of doing that. Simply trying to "save and exit" after opening the element without even doing any changes to it gives me the same error. So this obviously is a database error not a Fabrik error. And it seems to be just this element: I have tried other elements and they "save and exit" without problem.

The problem is still unsolved. At lease we do know now that it is purely a database problem.
 
Try deleting and retyping the element name (not label). It's possible you've gotten some non printing characters in there, or maybe a trailing space.

-- hugh
 
I finally figured it out. I post the solution here in case somebody else encountered a similar problem in the future. The problem was exactly what the (typically cryptic) error message said: a duplicate column name. Not in the same table, mind you. I had completely forgotten that I had a separate table for countries and in it was a field named country. When I changed the name of the field that is causing me trouble slightly the problem disappeared. I still think that this shouldn't have been a problem in the first place since the identical names were in two separate tables, but who knows what a database inner workings are like. Anyway, if the problem is solved, I am happy.

Thanks a bunch to lousyfool for drawing my attention to predefined javascript actions and to Hugh who helped me correct my investigation focus. People of the Fabrik community: you are the best.
 
Same name in a different table should have no effect, and I've never seen anyone have that error before. So something wierd in your setup.

-- hugh
 
The only thing I can think of is that in the Country table the column "country" is key. I am not sure whether that had an effect on what was going on.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top