Problem with databasejoin

Dz

New Member
Hi Guys,
I have been created a form with a databasejoin element , but in the "list" view this field contenent doesn't appair and when i try to modify a record that element result not applicated.
That element show the italian provinces..
In the PhpMyAdmin the field is filled!
What could it be??
it's driving me crazy :D
 

Attachments

  • Schermata 2016-04-06 alle 08.23.45.png
    Schermata 2016-04-06 alle 08.23.45.png
    162.7 KB · Views: 130
  • Schermata 2016-04-06 alle 08.30.06.png
    Schermata 2016-04-06 alle 08.30.06.png
    1.3 MB · Views: 119
  • Schermata 2016-04-06 alle 09.04.45.png
    Schermata 2016-04-06 alle 09.04.45.png
    185.7 KB · Views: 132
I'm guessing that you're having a similar issue that I initially always had with selecting U.S. states.
If you can also provide a screen snip of the structure of the table being used by the database join, I might be able to help.
 
sure, here it is
 

Attachments

  • Schermata 2016-04-06 alle 17.32.31.png
    Schermata 2016-04-06 alle 17.32.31.png
    135.7 KB · Views: 144
OK thanks. It's exactly what I suspected.
It looks like you are using the 2-character text abbreviation (cod) for the Provincia as the key in your databasejoin. But Fabrik lists (and the databasejoin plugin) only work with primary keys that are numeric (i.e. the auto-incriment 'id'). So you will need to add an 'id' column (auto-increment integer) to that table.

I struggled with this for 2 years before finally doing it 'right' (for Fabrik). Sometimes it will appear to work if you use the text abbreviation as the PK - but will cause problems elsewhere (as you discovered).

To fix...
Edit that table (being used for the dbjoin) via phpMyAdmin and add a new field at the beginning of table.
Name: id
Type: int(11)
Extras: auto_increment
and set it as the primary key.

Then save the changes. (The new columns should be added with a new primary key index added to the table.)
Then go back into Fabrik and add that table as a new Fabrik list.
Then in the databasejoin element where you are using that table as the databasejoin 'Table' - set the 'Value' to use the new 'id' field (rather than the 'cod'). It should be shown in the Value dropdown selection as 'id [recomended]'. Save the edit of that element.

Your list should now show the 'Label' used in the databasejoin element rather than being blank.

Though, I'm just thinking, sometimes the dbjoin element doesn't like being messed with after it has already been configured - especially with changes like this where you edited the table outside of Fabrik. So if you have a problem (it still doesn't work) using the instructions above, just delete the dbjoin element entirely, empty the Element's 'trash', and add it back again.

If you want to show the Provincia abbreviation in the list and the full name in the form you would have to create a calc element that would get the 'id' used for the Provincia dbjoin element and query the Provincia table to get the abbreviation (cod). Then show that calc element in the list but hide it in the form.
See Wiki: http://fabrikar.com/forums/index.php?wiki/calculation-element/

I'm just thinking - a nice feature for the datbasejoin element would be to have 2 'Label' options - one label to be used if rending in a list and one for rendering in a form/details. THAT would solve this common problem.:cool:
 
I thought you dropped off the face of the earth and my response was all in vain.:(
Glad to help.:)
 
Back
Top