Dropdown checkbox combo

tcranford

Member
I've had success creating a data driven multi-select dropdown using the traditional ctrl-click interface to select multiple entries. Now I'm looking for a potential alternative that may be somewhat more obvious for a user to select entries. My challenge is that my list could be rather lengthy and one miss-click and the user's work in selecting entries could be undone.

Has anyone had any success creating a dropdown element that is composed of checkbox items? Such as the attached example below...

Thanks!
 

Attachments

  • dropdown-checkbox.jpg
    dropdown-checkbox.jpg
    53.5 KB · Views: 45
You can set your dbjoin to Render=checkbox (I think this has the same underlying structure as multiselect, but backup before modifying the element type).
Options per row =1 (or whatever you need)
Add custom CSS to your element, e.g. {height:100px; overflow:auto;} to limit the size and get a scrollbar
 
Hey troester,
Thanks for your response! After testing the dbjoin element works well and is the look that I need. However, I need more control over the number of dropdown items that are put in the list. For my use case there could be zero to hundreds of rows returned that are eligible to be entered into the dropdown. I need better control over the "where" clause of the query to further limit returned rows. Prior to me asking the question I had used a dropdown element with PHP code within the Advanced tab, "eval populate" option to control the number of dropdown items added to the list. This option allows me to build my own query for dropdown population whereas the dbjoin element option does not.

Other thoughts? Thanks again!
 
Can you define "better control over the where clause"?

You can do anything in that clause which is valid MySQL. If you need something complex, rather than a simple "WHERE published = 1" or whatever you can use a subquery ...

WHERE {thistable}.id IN (SELECT id FROM ... some big complex query with joins, or limits and anything else you need that selects a set of ids of your joined table...)

-- hugh
 
Hmmm, ok...I'll give it a try! To that end is it possible to use other element placeholders within the "Data Where" tab in the "Joins where" section? I've tried to reference several values within the form using the {cust_search___last_name} format with no joy. That field is included in my form though in a different group. In this instance I'm using a multi-page form.

Thanks!
 
Yes, you can use element placeholders in the WHERE clause. Won't work for repeat groups (or at least, not in any particularly useful way). Although of course when loading a new form, those placeholders won't have a value (unless you provide a default for those elements). But if you select the "AJAX update" option, we will watch any elements you use as placeholders, and when they change on the form, we will automatically rebuild the join element options via an AJAX call.

-- hugh
 
No joy on using element placeholders within the where. At first I was attempting to do that using a checkbox render-as option (what I really need) and then I noticed that the tool tip for the ajax update control mentioned that placeholders currently only work with a dropdown render-as option so tested that...element placeholders still didn't work. I'm noticing that the placeholders are being substituted for a null value which acts like the element reference isn't correct though I've triple checked them all. My current code isn't reachable from the outside world so I won't be able to grant access to my server so I've included several screen shots of my setup in hopes that it will help with my problem.

[edit] Forgot to mention that I've set default values for each of the three query fields that are used within the form. So I would assume that upon entry into the form the query would run with the placeholder substituted values.

Running current J! and latest github Fabrik.

Thanks!
 

Attachments

  • problem_1.jpg
    problem_1.jpg
    93.4 KB · Views: 34
  • problem_2.jpg
    problem_2.jpg
    108.7 KB · Views: 35
  • problem_3.jpg
    problem_3.jpg
    182.3 KB · Views: 35
  • problem_4.jpg
    problem_4.jpg
    108.8 KB · Views: 41
Last edited:
I really can't do much unless I can get at the server. Kind of like asking a mechanic to diagnose an engine problem over the phone.

One thing, you'll need to quote those placeholders in your query, like ... foo = '{yourtable___foo}', otherwise they'll blow up even when they have values.

Placeholder replacement in the WHERE query, and AJAX updating when those elements change, definitely works, I do it all the time.

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

Thank you.

Members online

Back
Top