248 Posts
Giuse
7 years ago
3
Topic

Hi, I think I am facing a serious dynamic cascade bug but I don't understand why.. 

Let's take the usual scenario with countries/cities to be associasted to users and put 2 cities with same name "CitySame" in different countries (of course) like CountryA and CountryB where CountryA's cities are before CountryB's ones in the DB table of country-city association.

Everything works fine when creating a new association, you select CountryB from first stage and in the second stage only cities in countryB are selected. Choose CitySame and save. Saved values are correct.

Then edit this association: you get CountryB in the first list and... CitySame in the second as one entry of list of cities of countryA! Infact if the second field displays a translated name [lang] instead of the value, you will clearly see that it is showing elements from CountryA and not from CountryB (also the displayed CitySame is the wrong one).

If you select a city that does not have a duplicate in another country, everything works fine. It's just as the cascade field is not using correctly the parentId while editing and showing... Can anyone confirm? For me it's a serious issue since of course in reality there are cities with same name.

Thanks

Giuse

Get a Book for SEBLOD
4229 Posts
Kadministrator
7 years ago
1
Level 1

I can't reproduce this in Construction mode and with numbers as ids for cities. What is your setup?

248 Posts
Giuse
7 years ago
0
Level 2

My setup:

  • country table is the default one provided with Seblod installation.
  • on the second and last level I am using "regions": the table has the following columns:
    • id
    • code2 - is the reference to same column in countries table (the 2 letters country code)
    • region_code - the code of the region
    • region_name
  • So option name = region_name, option value = region_code, parent = code2.

    Then you just need some regions for 2 countries, important is to have something like Utah in USA {id1, US, UT, Utah} and Uttarakhand in India {id2, IN, UT, Uttarakhand}.

    The test: create a new location for a user setting country = India, in the second dropdown you will see the list of Indian regions, select Uttarakhand and save. In the DB we get correct values {IN, UT}.

    Now edit or display that location: you will get India/Utah and the dropdown presents the list of American regions and not Indian ones.

    Proof test: select another region for India and everything works fine.

    Available for more details if needed.

    Thanks

4229 Posts
Kadministrator
7 years ago
0
Level 1

You need to have unique identifiers for each region, if you just switch region code with id in second select option value it will work as ids are unique. Alternatively you can change region code for each region so that it is unique.

Get a VIP membership