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

cascading drop down's

Hi, Experts!

So i have database and lists joined to this database.

in database we have: 70 counties; 600 cities belonging to this countires, 1300 institutes belonging to this cities; 3200 participants belonging to this institutes; and 11 statuses.

So, the task is how to if i choose 1 country for ex Germany, in the next menu -- > will be the list with only German cities, than in institute drop-down menu will be only German institutes belonging to each German city etc...

Now i have not joined menus. and drop-down in every menu shows all of the elements.

How can i do this without changing the structure (may be adding some prefixes)??

P.s i also download cascading drop-down plugin, but could not configure it in my way.

Thank you!
 
You haven't described your table structure. Does it look something like this ...

counties
id, county_name

cities
id, city_name, county_id

institutes
id, institute_name, city_id

participants
id, participant_name, institute_id

... where in each case 'id' is the PK (primary key) of that table, and <foo>_id is an FK (foreign key) pointing to the PK of the "parent" in the preceding table?

-- hugh
 
You haven't described your table structure. Does it look something like this ...

counties
id, county_name

cities
id, city_name, county_id

institutes
id, institute_name, city_id

participants
id, participant_name, institute_id

... where in each case 'id' is the PK (primary key) of that table, and <foo>_id is an FK (foreign key) pointing to the PK of the "parent" in the preceding table?

-- hugh

mmm.. No
now it it looks like this:

countries
id, country_name

cities
id, city_name

institutes
id, institute_name

participants
id, participant_name

status
id, status_name

so now, my
what should i do to set up the keys? how to order it usign keys?
 
OK, well you'll need to modify your tables to include that FK, otherwise Fabrik (or anything, really) has no way of knowing which city belongs to which country, or which institute belongs to which city, etc. It's standard relational database stuff, "nomalizing" your data. Not Fabrik specific, it's just how you do the "relational" part of "relational database".

So to start, add a join element to 'cities', called country_id (so set the join element up so it selects the 'countries' table, with 'id' and the "value" and 'country_name' as the "label") and for each city, set it to the appropriate country ID. You can either do that by editing the rows individually in Fabrik, or go through in something like phpMyAdmin and poke the right numeric values in (so if "Germany" is id 3 in your countries table, the country_id for Munich is 3.

So to answer you question ...

How can i do this without changing the structure (may be adding some prefixes)??

... you can't. Relational databases work by having primary keys (PK) and foreign keys (FK) that define the relationships between rows in tables.

-- hugh
 
Once you've normalized your tables with FK's, the CDD element will work - so (say) assuming you have a "Countries" join element and a Cities CDD, under the CDD "Watch" tab, you would set the "Watch Element" to your "Countries" join element, and the "Foreign Key" to the "Country ID" on you cities table. Then when the user changes the selection for Countries, the CDD will redisplay, showing only cities with the select country_id.

-- hugh
 
Ok well it is work
but

an ADD button to my Cities list is disappear, and when i choosing CDD plugin for this list - menu option with ADD button also dissappear. How i can add this button?

upload_2019-6-25_12-35-46.png upload_2019-6-25_12-36-32.png

there is on menu. but the menu with ADD Countries button is here

when you want to add new Country in the database.

look
upload_2019-6-25_12-38-10.png


So when i use CDD i cant add a new element City to the database?????
 

Attachments

  • upload_2019-6-25_12-36-18.png
    upload_2019-6-25_12-36-18.png
    235.3 KB · Views: 99
So when i use CDD i cant add a new element City to the database?????

No, you can't!!!!!?????!!!!?????????

Well, not with an "Add" button on the element. You can always add with normal Fabrik list/form usage on the appropriate list. But no, CDD's don't have the "Add" feature.

If you want to have users add to those (and trust them to know what country a city is in, or what city an institute is in, etc. so they can set the FK join when adding the record), then you'll have to go back to using join elements instead of CDD's (just change the plugin type from CDD back to databasejoin), and make them behave like a CDD by doing this:

For example, on the 'city' join, add a "WHERE filter" like this:

Code:
WHERE {thistable}.country_id = '{yourtable___country_id_raw}'

... and set "AJAX update" to Yes.

In that WHERE clause, leave {thistable} as is, and change country_id to whatever the country FK field is called on your city table. And change yourtable___country_id_raw to be whatever the full element name for the 'country' join on your form is, with _raw appended. Leave the quotes and curly braces intact.

Fabrik will then automatically "watch" the 'country' join dropdown on the form, and when it changes, will do an AJAX update for the 'city' element, which will then filter to just cities with that country_id, and update the available options in the dropdown. This is basically exactly what a CDD does, you're just building it by hand.

You'll then need to change the institute element the same way.

Then of course you can enable the "Add" feature on those joins.

Note that you'll need to have the FK elements (like "Country" on the City form) as visible and editable, so the user can set them when they add the City (or whatever).

-- hugh
 
Also note ... I don't think nested popups will work. So for example, don't enable "Add" for the "Country" join on the "City" form, expecting them to be able to pop up an "Add" on your main form for the City, then from that pop up an "Add" a Country.

Having said that, it *might* work, but I seem to recall it doesn't. So ... just don't assume it will. And if it doesn't, don't post "Can't I add a new Country from the City popup????????????????". :)

(Sorry, use of multiple punctuation like ?????? triggers me, I don't know why. Just seems like the punctuational equivalent of "wtf?")

-- hugh
 
thanks for big answer and sorry for --(wtf?). have to try your described 2 way. but now use such "add button" by adding new modules and attach the forms with adding cities and institutes to them.
 
I think the only problem with using modules to do that is they will submit via AJAX, without refreshing the page, so any rows you add to those lists won't immediately appear on the dropdowns in the form on the main part of the page. That's why we provide the "Add" button for the join element, so the dropdown options get updated in place when you add the new row.

-- hugh
 
hi, i checked this by adding from the module a new city element with choosing the country id in this module also. This module is with AJAX. then i went to my list "Collaboration" and - yes a new city element is appeared in drop down menu "City" without refreshing page.

Thanks.
 
Hello, i've done CDD but have some question:

1."countries" it is Database JOin unique list checking
id, country_name

2."cities" CDD (country_id) unique list checking
id, city_name

3. "institutes" CDD (city_id) non-unique data
id, institute_name

4. "participants" CDD (city_id) unique list checking (city_id) ---> want to set up CDD (institute_id)
id, participant_name

5. "status" it is Database JOin unique list checking (status_id)
id, status_name


so, in the 3. institte database i have non-unique data (for example -- there are "Univ."which repeating 56x times and many other ... "CU" - 5 times..) and if i want to ADD then a new participant you have to choose (from which Univ. from that list with 56-x (full names is only in institute database). Moreover, not only me but 55 users need to add a new participants inside database and of course they don't know which "Univ." they have to choose.

So, in my opinion, is it possible to check by CDD simultaneously 2 fields (city_id + institute_id) and then it will be shown us only participants from that university of that city (and when we want to add a new participant also)?


Thanks!!
 
Yes, you should be able to add a "WHERE filter", so on "participants", add the where clause ...

WHERE {thistable}.institute_id = '{yourtable___institute_id_raw}'

ie. match the institute_id of the table you are joining to, with the one from your form.

-- hugh
 
No, you can't!!!!!?????!!!!?????????

Well, not with an "Add" button on the element. You can always add with normal Fabrik list/form usage on the appropriate list. But no, CDD's don't have the "Add" feature.

If you want to have users add to those (and trust them to know what country a city is in, or what city an institute is in, etc. so they can set the FK join when adding the record), then you'll have to go back to using join elements instead of CDD's (just change the plugin type from CDD back to databasejoin), and make them behave like a CDD by doing this:

For example, on the 'city' join, add a "WHERE filter" like this:

Code:
WHERE {thistable}.country_id = '{yourtable___country_id_raw}'

... and set "AJAX update" to Yes.

In that WHERE clause, leave {thistable} as is, and change country_id to whatever the country FK field is called on your city table. And change yourtable___country_id_raw to be whatever the full element name for the 'country' join on your form is, with _raw appended. Leave the quotes and curly braces intact.

Fabrik will then automatically "watch" the 'country' join dropdown on the form, and when it changes, will do an AJAX update for the 'city' element, which will then filter to just cities with that country_id, and update the available options in the dropdown. This is basically exactly what a CDD does, you're just building it by hand.

You'll then need to change the institute element the same way.

Then of course you can enable the "Add" feature on those joins.

Note that you'll need to have the FK elements (like "Country" on the City form) as visible and editable, so the user can set them when they add the City (or whatever).

-- hugh


I have problem with setup where country >> state >> city cascading using database join. I have nice cascade using Database field with WHERE Ajax filter for FORM VIEW, but in LIST this is not happening. I have selected Dropdown option in LIST FILTER for all three Database elements Country / State / City. The country element shows all countries in dropdown as expected.

BUT when I select any STATE from Dropdown in LIST, the cascade for STATE Filter do not work. It displays default 'All' with no Dropdown options.


I have checked with Protostar template + Frontend/Backend. But same error. Is this Bug or Limitation of using Database Element instead of Cascade Element (I would like to use Database element, as it provides option to add State / City on fly). Navigation option of List is 'Non-Ajax'. Enhanced Dropdowns is set to 'NO'.

Database Filter.png

NB: Apologies for using this Thread, instead of creating a new one.
 
Last edited:
Check "Filter data" setting in List view settings->filters.
If set to "Recorded data" and you haven't records you can't view anything.
 
Check "Filter data" setting in List view settings->filters.
If set to "Recorded data" and you haven't records you can't view anything.
Thank you for taking time and providing hint.

I set to "Recorded data" in Element Filters and put 1=1 in Filter Where (DB join element > Data Where), now the state / cities options are showing in the LIST. I don't know whether this is the Correct solution, but it is working in LIST dropdown filters. I wish it should have Ajax Filtering in the LIST like what available in FORM (when you select country, it auto populates the states options of that particular country).

Regards
 
CDD's should work normally as filters, so when you change the filter for the element a CDD "watches", it should repopulate.

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

Thank you.

Members online

Back
Top