• New Commercial Services Section

    We have now opened a commercial services section here on the forum. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.

    Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.

Database join, Cascading drop down, Add new

Mono

Member
Hello

I'm a newbie to Joomla and Fabrik but trying my hand to see how it worksI want to persevere because Fabrik seems great.

I have been struggling for a few days now with what I expect is a simple problem.

I have three tables relating to vehicles 'Tbl_make', 'Tbl_model', 'Tbl_vehicleDetails'.

'Tbl_make' has fields 'makeId' and 'make'
'Tbl_model' has fields 'modelId', 'model' and 'makeId'
'Tbl_vehicleDetails has 'LicencePlate', 'makeId' and 'modelId'

I have no problems here having used database join and cascading dropdowns works a treat.
However at data entry of vehicleDetails I need the user to be able to add data to 'Tbl_make' and or 'Tbl_model'.

At the highest level I can use the add function, but in the cascading dropdown its not available.

I had then decided to have a selection in the dropdown of "Add new model", when this was selected it would enable a text box to enter the new model. I can't however get my head round the task.

Or if there is a better way I'd love to hear it?

Mono
 
I assume that you talk about the form of the "Tbl_vehicleDetails" and from that form it is possible to add new data to the other two table if it was a db_join (with the 'add option in front end'), but not with cascade-dropdown.

What you could do is to use access-levels for the elements in your "Tbl_vehicleDetails" table:
The element of 'make' could be like this add=public and edit = super-user.
And all the other elements add=superusers and edit=registered.

Then you go to Fabrik-Form and create a Re-direct plugin. And the red-direct URL will be again the same form with {rowid} at the end of your URL.

The go back to elements and make a database-join element to the 'Tbl_model' table with a Filter at "Data-WHERE"
Type at SQL: WHERE{thistable}.ID = {Tbl_make___Make_raw} And apply WHERE to Edit and not to both, to prevent an error.
Further you can set Add option in front-end to YES.

In this way your users fill in the form in 2 steps. First the made and than they can select the model based on the made and they can also add new models if the model is not in the list because of the front-end option, which you don't have in cascade dropdowns.

After saving the edited from the user will again go to the same form, so there should be another plugin in the form to redirect to a desired page after editing the from.
 
What you could do is use a join for Tbl_model instead of a CDD, by using the "AJAX where" feature of the join element. This allows you to set up a WHERE filter using element placeholders, like ...

WHERE {thistable}.make = '{myform___model_raw}'

... (obviously replace that element name with the one for the 'make' on your model table, but keeping the _raw suffix), and enable the "AJAX where" feature. THis will then automatically watch any elements you have placeholders for in the WHERE clause, and update the join whenever one is changed, with the new value for the element in the WHERE clause. Which is basically what a CDD does.

Then you will have the "Add" feature for both.

-- hugh
 
Thanks both of you.
Cheesegrits your solution I have used and it works great.

But marozen your answer is interesting and I'm going to look at it with regards to another problem.

Thanks again
Mono
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top