CMS Development

adamfeldt
参加者

How can I add a hidden multiple choice field to a landing page

解決

I am trying to add a 'choice' field to a template, in order to be able to send some values to the API that I can use on my website. I need to send multiple values however, as far as I can see, I can see, my only choice is to add single-choice dropdown fields using the HubL 'choice' term. Is there a way for me to create a multiple-choice field??

0 いいね!
1件の承認済みベストアンサー
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How can I add a hidden multiple choice field to a landing page

解決

@adamfeldt Oh, I see. Here's an idea... use multiple boolean module's and then create if statements around that:

{% boolean "option_one" , value=False, no_wrapper=True, export_to_template_context=True %}
{% boolean "option_two" , value=False, no_wrapper=True, export_to_template_context=True %}

{% if widget_data.option_one.value == False and widget_data.option_two.value == False %}
// both are false
{% elif widget_data.option_one.value == True and widget_data.option_two.value == False %}
// one is true
{% elif widget_data.option_one.value == False and widget_data.option_two.value == True %}
// two is true
{% elif widget_data.option_one.value == True and widget_data.option_two.value == True %}
// both are true
{% endif %}

Not as easy as having a simple 'multiple select' attribute for the choice field, but gets the job done. Should probably add that to the HubSpot Ideas board.

Stefen Phelps, Community Champion, Kelp Web Developer

元の投稿で解決策を見る

6件の返信
stefen
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How can I add a hidden multiple choice field to a landing page

解決

@adamfeldt is there a reason why you don't want to use checkboxes? This is kind of the standard when it comes to multiple selections.

Stefen Phelps, Community Champion, Kelp Web Developer
0 いいね!
adamfeldt
参加者

How can I add a hidden multiple choice field to a landing page

解決

Hi Stefen,

Well my primary reason is that I can find no HubL syntax for adding checkboxes. I can only find 'choice' and that just gives me drop-down's with single choice.

0 いいね!
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How can I add a hidden multiple choice field to a landing page

解決

@adamfeldt Oh, I see. Here's an idea... use multiple boolean module's and then create if statements around that:

{% boolean "option_one" , value=False, no_wrapper=True, export_to_template_context=True %}
{% boolean "option_two" , value=False, no_wrapper=True, export_to_template_context=True %}

{% if widget_data.option_one.value == False and widget_data.option_two.value == False %}
// both are false
{% elif widget_data.option_one.value == True and widget_data.option_two.value == False %}
// one is true
{% elif widget_data.option_one.value == False and widget_data.option_two.value == True %}
// two is true
{% elif widget_data.option_one.value == True and widget_data.option_two.value == True %}
// both are true
{% endif %}

Not as easy as having a simple 'multiple select' attribute for the choice field, but gets the job done. Should probably add that to the HubSpot Ideas board.

Stefen Phelps, Community Champion, Kelp Web Developer
adamfeldt
参加者

How can I add a hidden multiple choice field to a landing page

解決

Hi Stefen,

Thank you for your effort. I have started this up in Ideas. the Boolean option is too hard to manage and takes up a lot of UI real-estate.

Thanks anywho

8^)

Adam

0 いいね!
ChadP
投稿者 | Elite Partner
投稿者 | Elite Partner

How can I add a hidden multiple choice field to a landing page

解決

You can always use javascript to change the feidl to a multi value. But that would only work on the fromt end.

 

$('select').prop({'multiple':'multiple'});
0 いいね!
adamfeldt
参加者

How can I add a hidden multiple choice field to a landing page

解決

Thanks, but I would like to avoid that approach.

0 いいね!