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

form, dropdown box - values from db

tkj

New Member
Hi can anyone tell me, if its possible to create a dropdown box on a form, from where the value/label comes from a table instead of the current system where i need to manually enter the values by pressing add element under the formelement.

Since i have over 30 currencies, and uses those on different places on the site, it seems not appropiate to enter those values a lot of places :)
cheers
T
 
Hi

The best option is to first of all create a table to contain the list of currencies:

  • Create a group with a name "currencies"
  • Create an element (type field) called "currency" which belongs to this group
  • Create a form called "currencies" which contains the group "currencies", checking the "Record Form data in Database:" check box
  • From the list of forms, find the entry ("currencies") you have just created and click the link 'Create table view' at the end of the row
  • This will take you to the "add table" form
  • Give the table a label of "currencies"
  • Make a note of the "Database Table to link to" setting found under the data tab, as you will need this later on
  • Set the table to be published and press "save"
  • From the list of tables find the "currencies" table and click on the "view database" link next to it.
  • Click on the "add record" link
  • Enter all the curencies you wish to use

Then for all you other tables you can create a database join element which will be displayed as a dropdown populated with the data in the currencies table:

For brevity I will presume that you already have you table created, and simply need to add in the new currencies drop down to it. Lets say that you're table, form and group are called "Invoices":

  • Create a new element, called "currency" and assign it to the "Invoices" group.
  • Select "database join" from the element type list
  • Select "site database" from the "Connection" drop down
  • Select the name of the database table that you noted down when creating the table view, (it will be something like jos_fabrik_formdata_1)
  • For "Table's Foreign Key Column" select "fabrik_internal_id" - this is the data recorded in your Invoices table and is the id for the currency
  • For "Table's Foreign Value Column" select "currency" - this is what is shown in the Fabrik table.
  • Check that the element is published and press save

The advantage of this route is that if you add, alter or delete currencies in the currencies table then those changes are instantly available in all dropdowns created in the above fashion

Hope that makes sense, if not post your questions here

Cheers
Rob
 
Is there a way this work on the table itself allowing you to see for a given column all previous items already entered and either selecting from these values or being able to add a new value (for exemple a column "supplier" will have a drop down with all supplier already entered and the capacity to add a new supplier oif needed) ?

Daniel
 
hi Daniel

I'm not sure what your suggesting is a good idea. It would be better database design to put suppliers in a supplier table and access them from there.
There's currently no option to add in a record to a table whist editing a form, which is what you would need to achieve what you are after.

Cheers
Rob
 
Hi Rob

Thanks... still I believe this is a very useful option that I use all the time with Access...

Daniel
 
I think you bring up a good point Dan. I know I'm going to be doing the same thing on my site. I will have movies in a database that have been entered in by a user. If possible I want a specific movie to only be entered once. A movie can be associated to many users. If I am adding a new movie to my list, then I want to be able to select a move from the master list and add it to my list.

I'm sure this will be possible and will let you know what I figure out.

In the meantime, I have a question. I have a dropdown box in my form that works great. However, when I am viewing a record that is already in the database, all of the other fields populate with the value that is stored in the database. But the dropdown box does not and only shows Please Select.

If I select the correct value and then click on Save, I get a huge SQL syntax error!

Any thoughts?

Cheers,
Ray
 
Hi Rob.....sure. Do you have an e-mail or IM that I can send you some private login information? I'd rather not post it in the forum.

Another thing I noticed last night. The long SQL statement was actually one SQL statement but was duplicated. It was showing up twice in the error. So I wonder if it was running twice?

The other weird thing is that when I checked the site this morning. The error is gone. However, I haven't tried to go and repeat my steps from last night because I'm afraid it will break it again.

Thanks,
Ray
 
Drop down on edit..

Hello,
I posted the same thing 1 or 2 days ago, i didn't see this thread.
I have the same problem, on edit form, the drop down stay on please select....
Do you find a solution in 2007 ?
Thank you!!
 
Even if we did, as I recall you are using Fabrik 2.0, so the solution almost certainly wouldn't apply.

Can you point me to the new thread you started?

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

Thank you.

Members online

No members online now.
Back
Top