Buy Now
Sign in

How to apply a selected drop-down value as a filter in a list of results

farscape , May 31 2018, 01:06
F
farscape 118
May 31 2018, 01:06 #378052
Hi. I'm test-driving CC6 before buying it, and I'm stuck.
'
The goal is to use CF6 for a form to capture survey results.
  1. I'm able to create a dropdown with the name question_dropdown which reads a table that contains questions and their key. The dropdown list the questions. The field name (if that's the appropriate term) is choose_question.
  2. I'm able to create a function that reads the data from the results table using {var:read_answer_table}. Each record of the results table contains

    answers.user_id
    answers.question
    answers.answer
  3. I've created a task button with the event set to view.
  4. I have an event called view, which contains:

    {fn:read_question_table}
    {view:question_dropdown}
    {view:task_button7}
    {fn:read_answer_table}
    {view:Responses}
  5. The function that reads the data has a where clause that begins answers.question: and tried concluding it with {data:question_dropdown}, {data:choose_question}, {var:question_dropdown}, and {var:choose_question}.
On load, the table shows all results, which I might expect. When I change a value in the dropdown and click the button, nothing changes. I am unable to figure out how to apply the dropdown selection as a filter for the results table. I cannot find any examples of this in the forum or FAQs. Any suggestions?
Thanks!
healyhatman 7
May 31 2018, 14:15 #378063
Try question:{data:blahblah} instead of answers.question
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 10 2018, 13:56 #378224
Thanks Healyhatman! That helped. The problem that remains is that I can't figure out what goes in the {data:} to pull in the value chosen in the dropdown. The debugger always shows it filtering on a blank (that is WHERE 'answers'.'question' = ''). I've tried:
question:{data:question_dropdown}
question:{data:choose_question}
question:{data:question_dropdown.choose_question}
The dropdown is using a key/value par of aid/question, so I've also tried:
question:{data:question}
question:{data:question_dropdown.question}
question:{data:choose_question.question}
All return blanks.
If I hard-code a response, such as question:3, the value shows up where you'd expect in the debugger, and the number of rows returned is the correct number, but the rows are all blank - only the column titles show.
So I'm still missing something regarding passing the selected value, and when I hard-code a selection, the rows are blank. In the table view, if I check "Include all provider fields", they appear.
Anyone have suggestions? Thanks in advance.
healyhatman 7
June 10 2018, 14:13 #378225
{data:the ***NAME*** of the field you're sending}
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 10 2018, 14:30 #378226
Thanks. I apologize that I can't interpret your instructions accurately. I thought I had tried that.
Below is the configuration of my dropdown. the read_question_table pulls in a key/value pair aid and question. So is aid, choose_question or question_dropdown the name I should use? I've tried all three as question:{data:name}. All result in a blank in the WHERE clause.
CC6_dropdown.JPG
Attachments
CC6_dropdown.JPG
CC6_dropdown.JPG
(76.69 KiB)
468 Downloads/Views
healyhatman 7
June 11 2018, 06:13 #378230
Post a screenshot of your read data action too.
But you should be using {data:choose_question} given the screenshot above.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 12 2018, 00:14 #378245
Here you go. Thanks!CC6_read.png
Attachments
CC6_read.png
CC6_read.png
(127.98 KiB)
434 Downloads/Views
healyhatman 7
June 12 2018, 00:39 #378246
And you're saying that's not working? Post the full {debug:}.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 12 2018, 00:51 #378247
Array
(
[option] => com_chronoconnectivity6
[cont] => manager
[conn] => survey-test
[event] => view_results
[_ga] => GA1.2.226007831.1505575861
[d3508fe47fbbb778d05025c46e258135] => YNX3ABvKytnF6DN-IVUQp3
[_gid] => GA1.2.426107557.1528764510
[d9ea4a41f5083d795fbc162759f58701] => 9k19Bc-rFD2Vx6Q-JibUj3
)
Array
(
[read_question_table] => Array
(
[log] => Array
(
[0] => SELECT `questions`.`aid` AS `questions.aid`, `questions`.`question` AS `questions.question` FROM `inyht_cf_questions` AS `questions` LIMIT 100;
)

[var] => Array
(
[1] => Test question 1
[2] => Test question 2
[3] => Test question 3
[4] => Test question 4
)

)

[read_answer_table] => Array
(
[log] => Array
(
[0] => SELECT `answers`.`user_id` AS `answers.user_id`, `answers`.`question` AS `answers.question`, `answers`.`answer` AS `answers.answer` FROM `inyht_chronoforms_data_test` AS `answers` WHERE `answers`.`question` = '' LIMIT 100;
)

[var] => Array
(
[0] => Array
(
[answers] => Array
(
[user_id] => 204
[question] => 0
[answer] => Answer 5
)

)

[1] => Array
(
[answers] => Array
(
[user_id] => 204
[question] => 0
[answer] => Answer 5
)

)

[2] => Array
(
[answers] => Array
(
[user_id] => 204
[question] => 0
[answer] => Answer 5
)

)

[3] => Array
(
[answers] => Array
(
[user_id] => 204
[question] => 0
[answer] => Answer 5
)

)

.
.
.


[50] => Array
(
[answers] => Array
(
[user_id] => 204
[question] => 0
[answer] => Answer 5
)

)

)

)

)
healyhatman 7
June 12 2018, 00:53 #378248
So the choose_question field isn't being sent. Since this is in CC make sure the dropdown is inside a form and that you're sending that form when you submit.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 12 2018, 01:05 #378249
In the results, the value of [question] of zero exists in my test data. If I hard-code the WHERE to be 1, 2, 3 or 4, the resulting list includes the relevant records.
F
farscape 118
June 12 2018, 01:05 #378250
Sorry- sent that last before I saw your response.
healyhatman 7
June 12 2018, 01:06 #378251
In the {debug:} the first array doesn't contain choose_question which means it's not being sent to your event.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 12 2018, 01:15 #378252
I'm very new to CC6 ... I'll need to check out how to use the form properly, and then post an update.
Thanks!
healyhatman 7
June 12 2018, 01:16 #378253
Are you displaying data in a table? If not, does it NEED to be in CC or would you perhaps be better off making it in CF
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 13 2018, 00:11 #378268
The plan is to display the data in a table. I'm more familiar with CF, but I thought it might be easier to use CC for data filtering and display.
healyhatman 7
June 13 2018, 00:20 #378269
 Answer
Right well here's what you should probably do.
Call your dropdown as {view:name} (the TOP name field) in a Custom element inside a Fields element
Call your fields element as {view:fields_element_name} inside a Form element
Set the event to whatever you need it to be. I have mine set to {data:event} so I can use the filters fields on any event
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
F
farscape 118
June 13 2018, 00:57 #378270
Ah, that helped! It took a few trials, but it appears to be working. I was not using a form element, so the dropdown and the submit button were not in the right place.
Thank you very much!
P
PJNO 4
June 13 2018, 12:27 #378285
Call your dropdown as {view:name} (the TOP name field) in a Custom element inside a Fields element
Call your fields element as {view:fields_element_name} inside a Form element
Hi
I have same problem also, but I didn't understand what is fields elemet and how to call it?
Thanks in advance!
healyhatman 7
June 13 2018, 12:34 #378286
in CC there's a Fields element you can use, under Views
When I say "call" I mean use the shortcode to display or run it. So if the Fields element is named "myFields" you call it with {view:myFields}
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store