Solved: Storing author name data in a choice fields returns "Invalid Choices List"
Hello,
I am having problems trying to get a list of others as choices in choice module. I am able to get the list to the point of pulling everything correctly, the only issue is that I get “Invalid Choices List: [Dana Smith]”. Below is the code I am using:
{% set authors_choice = [] %}
{% set author_list = blog_authors('default', 20) %}
{% for author in author_list|sort(False,False,'display_name') %}
{{ authors_choice.append(author) }}
{% endfor %}
{% choice "author_two" label="Choose A Secondary Author", value="", choices="{{authors_choice}}", export_to_template_context=True %}
Solved: Storing author name data in a choice fields returns "Invalid Choices List"
@pmanca Honestly, I dont even need to include the author_list portion of code and instead can do this:
{% set authors_choice = [] %}
{% for author in blog_authors('default', 20) %}
{{ authors_choice.append(author) }}
{% endfor %}
{% choice "author_two" label="Choose A Secondary Author", value="", choices="{{authors_choice}}", export_to_template_context=True %}
Which still results in an Invalid Choices list. If you’d like I can send you the portal ID and link to the template where this is all at so you can see it.
I know this thread is very told, but would you be able to post your solutions for this? I’m trying to do the same basic thing and I haven’t been able to figure out the syntax to pass in the value label pair and to get past the error.
Solved: Storing author name data in a choice fields returns "Invalid Choices List"
@pmanca The code above pulls in a list of blog authors using the blog_authors HubL function (http://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#blog-authors). It’s then setting author_list to the this and using the for loop to go through it. Inside the for loop, I have it appending the author to the authors_choice variable so once the loop is completed, all the authors (limited to 20 in this case) will be in an array for the authors_choice variable.
This array is what is coming back as an Invalid choices list.