list records selected automatically through a radiobutton option

enzo2016

Member
Hello,
I would need to achieve the following situation:

The user adds his customers into a list (list a).
The user filling a form (form b) has to select an option from a radiobutton. This radiobutton let the user to select what list of people (customers list, vendors list, etc.) will be able to see the content of form b). Hence this radiobutton is useful because allows to choose which list of people can see the content filled in form b).

How can I achieve that? Could the view level element be useful for that?

Thanks.

Enzo
 
My main need can be compared to the following situation:
if a user fills a form, then the record is visible to everybody. My need is to limit the visibility of the record to the users who each user has already previously added into a list. For example we call this list "friends". So his records are visible only to his friends and not to everybody.

Maybe a prefilter could help, but I am not sure because I don't know how to set it. How could the situation, shown above, be managed? I think it should be a common need because maybe important.

Thanks

Enzo
 
So by "view" do you mean see it in the list, or open the details view for it, or both?

You might be able to do it with a pre-filter.

So does the 'friends' table have a structure like ...

id, userid, friend_userid

... with multiple rows for each user (one per user/friend combination), so say userid 123 has friends 125, 126 and 130, that's three rows in the friends table:

1, 123, 125
2, 123, 126
3, 123, 130

-- hugh
 
Thanks so much Hugh. By "view" I mean the list. For all of my tables, the list is enough, but sometimes could be useful to open the details view (but I thought that a link into a record of the list could show the details view).

Thanks

Enzo
 
I am not sure to answer properly:
- id is the ID of the table
- userid is the element recording the ID of the logged user
- friend_userid should be a databasejoin connected to the users table.

Sorry I can't imagine the settings of the join and the pre-filter.


Enzo
 
Last edited:
OK, I just needed to make sure that was the format you are suing, and not (say) a repeat group with the join in it for the friends, or a checkbox join, etc.

And I'm assuming you have a user element on the table you are wanting to control access to.

I'll have a think, see if I can come up with a way of doing it in a pre-filter.

-- hugh
 
I am not using any particular format because I don't know to carry out then. The only example I know about the join use is that into the videotutorial. I would not know how to create a join which automatically repeats all of the records (in this case the friends) for every new added record (for example the comments) in a different table (the comments table) or how to let choice what friends to add trough a checkbox.
Both of the ways are ok for me.

Thanks

Enzo
 
OK, so on list A, if you have a pre-filter like this:

WHERE
field: id
condition: IN
value: SELECT id FROM list_a LEFT JOIN friends ON list_a.userid = friends.userid WHERE friends.friend_id = '{$my->id}'
type: query

... that should mean users only see rows that they have a "friends" entry for.

-- hugh
 
Thanks Hugh. I have tested it, but the prefilter in frontend returns error: 500 Fabrik has generated an incorrect query for the list friends comments: <br />

I think I was wrong in the settings:

Tables settings:
tablename (element names):
friends (id, userid, friend_id)
comment (id, userid, comment)
friends comments (prefilter with: id, userid, comment)



Notes: I have created no join list manually between the friends and comment lists.


Prefilter settings:
Database table: comment
Primary key: id

WHERE
field: id
condition: IN

Value: SELECT id FROM comment LEFT JOIN friends ON comment.userid = friends.userid WHERE friends.friend_id = '{$my->id}'
Type: Query
Apply to: Registered





Are these settings wrong?

Thanks
Enzo
 
The prefilter was on 'friends comments' list (it is a copy of 'comment' list), but I have just tried it also in 'comment' list: this list shows without prefilter the records for the SuperUser (maybe because the prefilter is applied to Registered). The registered users see the error 500 written in my last post.




Enzo
 
Last edited:
After clicking the link, a page with the following message appears: "We are sorry, the page doesn't exist".


-- Enzo

P.S.: Happy New Year Hugh!
 
OK, query should be working now. I think it was an ambiguous field name (id).

BTW, if you enable J! debug mode, when Fabrik catches a query error it'll show you the actual MySQL error. We don't show that if debug isn't enabled, for security.

-- hugh
 
Thank you very much Hugh.
I have seen c1 and f1 into the Value field: for example c1.id or c1.user or f1.friend_id or f1.user.
What is the meaning about f1 and c1?

Thanks

-- Enzo
 
That was just me making sure that it wasn't a problem with the table names clashing with the same names from the outer query, although that wasn't the problem. The problem was not identifying the id correctly, as both friends and comments have an id field, so it has to be fully qualified, like comments.id, otherwise MySQL throws an "ambiguous field name" error 'cos it doesn't know which 'id' you want.

So you can remove those aliases if you want.

Code:
SELECT comment.id FROM comment LEFT JOIN friends ON comment.userid = friends.userid WHERE friends.friend_id = '{$my->id}'

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

Thank you.

Members online

Back
Top