Pages

Tuesday, October 12, 2010

Mencari data sesuai current user – Fabrik coyy

How can I ensure users only see records created by themselves?


In your form add a "username" element, called "username" This element automatically inserts the current user's userid into your form as a hidden field.
Now each time you users adds a record, via the form, to the database table, their user id is also recorded.
The second thing to do is to edit your table, and add a prefilter so that each user sees only the records that they have created:

  • Edit your form's table.
  • Select the "data" tab
  • Under the "prefilter" section press "add filter"
  • Select "username" from the field dropdown (the "username" element we previously created)
  • Select "EQUALS" from the condition drop down list
  • Enter "{$my->id}" (without the quotes) into the "value" field
  • Select "super administrator" from the filter drop down. NOTE ! - this means that the filter is applied to everyone EXCEPT the super administrator. So in our case normal users will see only their records, where as the super administrator will see all the records
  • Save your table

0 comments:

Post a Comment