1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Checkbox element - how to make no checkboxes until user adds them

Discussion in 'Standard Support' started by Bren, Apr 17, 2017.

  1. Bren

    Bren Member

    Level: Community
    Hello all.

    I have a form where the user would need to add 1 or more checkbox's to and then later check off the checkbox's. I think the checkbox element with the option for the user to add checkbox's will work; but I need the initial 1st checkbox to not automatically be there. I only need the add option in case the user adds any. Also, when the user adds the checkboxes the default of the added checkbox's needs to be unchecked. Is this possible?
    Thanks in advance.
     
  2. troester

    troester Administrator Staff Member

    Level: Community
    You can use a dbjoin element rendered as checkbox.
     
  3. Bren

    Bren Member

    Level: Community
    Cool. I didn't think of that. Thanks Troester.
    Going that route I'll have to create a sub list to reference. Is it possible for each record to start with a new empty sub list? I'm trying to prevent the user from having to search through a long growing list.
    Thanks in advance.
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You can achieve that by adding a user element to the lookup list, so when a user adds an entry it has their userid. Then add a pre-filter on the list as ...

    WHERE
    Field: userid
    Condition: EQUALS
    Value: {$my->id}
    Type: text

    That way, users will only see "their own" entries.

    -- hugh
     
  5. Bren

    Bren Member

    Level: Community
    Cool. Thank you, Hugh.
    If I want other users to see the same items; can I do something similar with the parent record ID (versus my->ID)?
    Thanks in advance.
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Maybe. Kind of depends what you are trying to do. Can you explain in more depth.

    Also, I misspoke, the filter would have to be on the element itself, in the Where fuller, not a prefilter on the lookup list. Like...

    WHERE {thistable}.userid = {$my->id}

    Sent from my HTC6545LVW using Tapatalk
     
  7. Bren

    Bren Member

    Level: Community
    Sure. I have a user who has been entering order #s in a text field element and then later updates an order ready date field element when all of the orders have arrived. Then a 2nd user receives an automatic email when this date ready field element has a value. The problem is that the 2nd user has been noticing that the 1st user has failed a few times with making sure all of the orders were received completely before updating the date ready field element. So, the 2nd user asked if I could add some more validation to the order number field by changing it to one or more checkboxes that the 1st user adds on the fly. I should also say that the parent record (which has one or more orders within it) is a single job or project. The 2nd user schedules each job only if all of the related orders have arrived first.
    I hope that helps. Thanks in advance.
     
    Last edited: Apr 18, 2017
  8. Bren

    Bren Member

    Level: Community
    Did my description help, Hugh?
    Thanks in advance.
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Nope, I'm completely confused now.

    Sent from my HTC6545LVW using Tapatalk
     
  10. Bren

    Bren Member

    Level: Community
    OK. Well, I tried to apply your suggestion (I think in the right place). I'm trying to make the dbjoin list items only appear in the records that they were created within. Attached is a snippet / screenshot of my attempt in the DBJoins Data - Where settings. It didn't work. When I added a couple checkboxes it appeared in all other record forms (per the 2nd attached snippet / screenshot). Any suggestions?
    Thanks in advance.
     

    Attached Files:

  11. troester

    troester Administrator Staff Member

    Level: Community
    The rowid is in the column parent_id and you must use the "Joins where and/or
    order by statement (SQL)" field
    I didn't test but try
    WHERE {thistable}.parent_id={rowid}
     
  12. Bren

    Bren Member

    Level: Community
    Thanks Troester. I tried it, per the attached, and as soon as I open the related form I receive than error (2nd attachment). Not sure why.
    Any suggestions.
     

    Attached Files:

  13. Bren

    Bren Member

    Level: Community
    Wish I knew the solution to this. I've tried the following and all it does is make all my check boxes go away.
    WHERE {thistable}.id={rowid}
    Basically, I'm just looking for checkboxes added within a form / edit to save to the related record and be visible to all users. Any suggestions?
    Thanks in advance.
     
  14. Bren

    Bren Member

    Level: Community
    Hello All.
    It took some extra work; but I got the following to work.
    WHERE {thistable}.fid={rowid}
    I had to add another field element to my lookup table called fid. I also added a PHP plugin to the form that saves the parent records ID to a session variable and some PHP to the default of the hidden fid field element to save the session variable to it. So, my database join checkboxes now work perfect when editing an existing parent form. Unfortunately, an error page appears (similar to the previous threads) when adding a new parent form record (obviously because the fid can't be loaded without an ID to lookup, yet). So, I'm forced to choose the "Edit" option in the "Apply where when" setting in the database join element to prevent the error page. I would finally be done if I could somehow hide the database join element in the form only when adding a new parent form record; otherwise all of the many many added database join element checkboxes would be shown during the form add. Any suggestions on how to hide an element on a form during the form add mode? Thanks in advance.
     
  15. Bren

    Bren Member

    Level: Community
    Friendly bump, anyone?
    Thanks in advance.
     
  16. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Put quotes around '{rowid}'

    I suspect the problem is that if rowid is blank (new form), the WHERE clause without quotes after we do the substitutions is...

    WHERE whatever.fid=

    ... without a value, which is a syntax error. Add quotes, and it'll be ...

    WHERE whatever.fid=''

    ... which is valid, and won't return anything.

    -- hugh
     
  17. Bren

    Bren Member

    Level: Community
    Hi Hugh.
    Yes, that worked! The error was gone on form additions. Thanks Hugh. Unfortunately, I still have the same issue. If the user now adds a checkbox in the DB Join during a form add then the new checkbox item isn't related to the parent record. So, the only solution I see is to hide the element during a form addition. Any suggestions on how to do so?
    Thanks in advance.
     
  18. Bren

    Bren Member

    Level: Community
    Hi Hugh.
    I was thinking maybe adding JavaScript to the parent ID element with a condition if null (during form add) onload would hide the dbJoin element. If that would work; could I trouble you for an example of the JavaScript that I would use?
    Thanks in advance.
     
  19. Bren

    Bren Member

    Level: Community
    Friendly bump, anyone?
    Thanks in advance.
     
  20. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Does it not work just adding that as an onLoad event to the parent_id element's Javascript actions?

    -- hugh
     

Share This Page