1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Open a form/page with a unique token

Discussion in 'Community' started by RobertG, May 21, 2020.

  1. RobertG

    RobertG Member

    Level: Community

    I create registrant records (not registered as users, only in this table) and other data where I insert a single complex token.
    I am looking for a way to later open front-end forms using this token to link this page to the right person's table row and use some of the data already registered.
    Is this possible with Fabrik?

    Thanks for your help!
    Last edited: May 21, 2020
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    If you have also the rowid (so the token is like a password) you can access the form with a link like
    + a list prefilter WHERE your-token-element EQUALS {t} (so public users must know the token to see a record)

    If you don't have the rowid use the "usekey" feature
    + a list prefilter WHERE your-token-element EQUALS {rowid} (so public users must know the token to see a record)
  3. RobertG

    RobertG Member

    Level: Community
    Thank troester. I will try to understand.

    Actually, I want to create a unique value in a field when saving the fist form. Then I want to use the token, added to the page URL, and use it to find the previous values on that first form/row to populate some fields of the new form.
    A minor student books a stay, give his data and his parents data. An URL for the new form (parent's agreement) with this token is sent to the parents. They use the URL that opens the agreement form associated with the first form data and their child.

    (In French, it would be easier to explain.... ;))

    In fact, I want to be able to use the same form (same base URL) for everyone and associate it using this token (URL+token) to a single line present in a table (nmne2_stay) to retrieve the name, date of birth, etc. and pre-fill the form, so that its record is well linked to this line (nmne2_stay).
    Last edited: May 21, 2020
  4. RobertG

    RobertG Member

    Level: Community
    I'm trying to explain it better: a student registers for a language course. His/her reservation is recorded in a table row, including his/her choices (date, type of course, accommodation...) and his/her personal informations. In this record, I add this unique identifier that I communicate to him/her with the addresses of two or three forms.
    These forms are one for additional information on his arrival and departure times and places, another for testing his knowledge and, if he is a minor, a third for parental consent.

    These three forms must use the identifier to link the information entered in these forms to the student and the stay he has chosen.
    Each student (and possibly his/her parents) will be able to access these forms, which this identifier will make it possible to personalise by pre-filling them with some of the data already known.
    The question is: how to use this identifier when loading the form.
    I imagine that I have to use a php plugin in the form parameters when loading the form to search with this token the row containing the student's data. But then, how can I fill in the form elements from this code?
  5. troester

    troester Well-Known Member Staff Member

    Level: Community
    In general:
    I would prefer to create a Joomla account for each student; otherwise it's up to you to make sure that the data can only be accessed via the "token" (because without having a Joomla user access all records must be principally public).

    If you use the rowid of the "main" record and take the token only for "manual" access restrictions you could
    • use the autofill plugin to copy the data
    • use list joins (joining the "main" list to the additional lists) so you don't need to copy the infos
    or use a php plugin onLoad to copy the data (then you can stay with only the token)
  6. RobertG

    RobertG Member

    Level: Community
    Thanks troester!

    I'm using juser plugin for teachers and accomodation families, so there is no problem to create users accounts for students and family.
    But the account will be used only twice for user (travel data and knowledge test), and one for parents, so I would have preferred to avoid creating these accounts for so few uses, but if it's the easiest, I'll try.
  7. troester

    troester Well-Known Member Staff Member

    Level: Community
    It's not necessarily the "easiest" (you must add prefilters like {$my->id} also if one user shouldn't be able to see other's data) but you must keep in mind to secure your data from "public"
  8. RobertG

    RobertG Member

    Level: Community
    Yes, it's the reason why actually (a "hand-made" script using Wumpa that hasn't been updated in 5 years I'm trying to replace with Joomla! and Fabrik)) this unique identifier is used to access the forms (mywebsite/portal/unique_identifier when mywebsite/portal returns a 404 error page).
  9. RobertG

    RobertG Member

    Level: Community
    I think I will use a simpliest way: when creating the form, I calculate a token for the student booking and send him/her in a summation/invoice so he/her could use the token in the head of the new form (travel date an hour, arrival and departure). If the student is minor, I create another token for the parents only, so they can open an agreement form corresponding to their child's stay.

    So I must now understand how to personalize two emails to send when validating the reservation form, one for the student, with all the information concerning his stay and his own identifier, the other, if necessary, to parents with their identifier and information concerning them (with two email plugins in the form). Care must be taken to prevent the minor student from accessing the authorization form intended for parents.

    I do not know what will happen for these emails, if I do not need the one for parents: a condition related to the date of birth of the student, in the second plugin email of the form?

    Otherwise, is it possible to dissociate the form where the informations of the parents of a minor student are entered (make it a standalone form), but to be able to open it in a tab of the main reservation form?
    I saw discussions on the subforms, but did not understand how they work.
    Actually, parents infos are in a separated group I reveal only if the student is a minor.

Share This Page