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

Conditioning elements on a table.

alekimn

New Member
I have two forms and i want to set them, that the conditions of form A, determines the display and input of form B.
like this...
Form A has an element with 3 dropdown. Form B has an element with a textbox. If a user chooses option one on the element in form A, the text box in form B, will disappear or change to read only. If the user chooses option 2 and 3 on Form A, the textbox on Form B can be edited.
I created both forms on a single database table, but the problem is that the JavaScript option(ready made ones) is not selecting elements on a dbtable, but is selecting elements in the same form, means i cannot set condition on elements in another form, despite sharing the same table.
I'm not a coding expert that why i need your help.
 
ok. Thats still a great idea, but here is the real scenario.

Code:
Form A               Form B
(dropdown)            (text area)
element 1            element 1(b)
element 2            element 2(b)

If user selects value 1 on element 1, then element 1(b) turns to read only. And if user selects option 2 and 3 on element 1, then element 1(b) can be edited.
The code should be run on every element of the form and i need a help on that code.
 
Not sure what you mean with "If user selects value 1... then 1(b) turns to readonly..."
If these are 2 independent forms the user doesn't select anything at this moment but somebody selected value1 and this was stored in the DB.

And what do you mean with "The code should be run on every element of the form"?
Should the complete form B be readonly if the dropdown in FormA has value1?

"despite sharing the same table." So you have a list A and a list B linked to the same DB table?

You could create a (hidden, readonly) element in list B linked to the column storing the dropdown from your listA.
This can be accessed via JS.
But following your description I have the feeling your are looking for something like the canEditRow list plugin.

BTW: Hiding (or making readonly) via JS is never a security means, a user can skip it. So if you have a editable element which must not be edited you must add a php validation (or a php form plugin) to "undo" editing if a user did so.
 
I'll try to use the js as you have said, , but to clarify things where you don't understand,
Here are the screenshots of the forms
Form A
Screenshot_20211130-054244.jpg
drop-down selection on Form A

Screenshot_20211130-054731.png
Form B
Screenshot_20211130-054310.jpg
They have same label(easy to differentiate), but different names, for dbtable.
if i choose "no change", in form A then i cannot edit that section on form B, but if i choose others, then i can be allowed to edit that section.
And that should go on to other elements. The values of drop-down are -1,1,2,3 respective.
Thanks..
 
Hi..
I came up with a better method(according to me) but I made things worse. I created a different dbtable for form B. I then created another table, and copied elements from form A and B, except id, date and time. I was trying to join the tables tongether, but i didn't complete.
I got an error on the browser and i cannot be able to edit the form anymore...
This page isn’t working right now
yourdomain.com can't currently handle this request.

HTTP ERROR 500

I was thinking of deleting the list and creating a new one, but i think i'll still encounter the same problem. How can i bypass this, please.
 
Can you access your backend and remove the join you made?

To be honest I also don't get what exactly are you trying to achieve.

From your last post I assume you had Form A and Form B referring to the same db table. So you get the same data from database when editing either form.

Or are you showing some elements in Form B which are not visible in Form A and vice versa. In that case you can hide elements with element js on load and "if some element value = something, hide another element".

But like @troester said, elements hidden by js can be unhidden by malicious users, so if there's a change it could happen, you should add extra php-validation to hidden elements.
 
Ok. One more Question. How can i append a unique id on a form during redirection to another form.
I mean redirecting from Form A to form B. Here is what i found while i was searching but i cannot understand how i can i append id from form A into form B id field without knowing it.
Forms | Fabrik (fabrikar.com)
Setting Field Data on Form Load (top)

When creating new records you can set the default value of your form's fields by appending key/values to the form URL:

E.g. if your form is located @ http://mysite.com/contact-us

and you have an element whose full name is contacts___name then you can fill the name field with the value 'rob' by using this url:

http://mysite.com/contact-us?contacts___name=rob

to set the value of dropdown elements/radio buttons/checboxes append '_raw' to the end of the full element name:

http://mysite.com/contact-us?contacts___agerange_raw=1
 
Honestly, @juuser and @troester I didn't know how to use js, back there, but after a dozen times of creating and dropping tables, installing and uninstalling fabrik, now i have the form working.
Thanks for your help and time.. I hope i'll also help someone with this type of problem someday..
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top