All Collections
Website
Theming
Form customization
How to request custom people fields on webpages
How to request custom people fields on webpages

This HOWTO assumes you understand the complexity of using custom fields and have already created custom people fields.

Updated over a week ago

📌 Note: Custom fields are available as add-ons. For more information on adding new features please see the add-ons page in your nation.

Table of Contents

Pages where custom people fields can be requested

Custom people fields can be requested on the following 10 action pages:

  1. Signup

  2. Donation

  3. Endorsement

  4. Event

  5. Feedback

  6. Invoices (within the invoice payment form only)

  7. Moneybomb

  8. Petition

  9. Survey (on the signup portion, not individual questions)

  10. Volunteer Signup

The example snippets below are formatted for use on a signup page and are styled for V2 Themes. To include these custom fields on non-Signup action pages, please use the example snippets provided for the following page types:

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

Liquid to request all custom people fields

The following code will request all custom people fields from your nation on a signup page:

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

{% for cf in custom_fields.signup %}

{% assign custom_field = cf[1] %}

{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

<div class="row-fluid">

  <div class="span12">

    {% if custom_field.is_text? or custom_field.is_number? %}

    <label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>

    {% text_field custom_field_id, class:"text" %}
 
    {% elsif custom_field.is_boolean? %}

    <label class="checkbox"  for="signup_custom_values_{{ custom_field.slug }}_custom">{% check_box custom_field_id, class:"checkbox" %} {{ custom_field.name }}</ label >
 
    {% elsif custom_field.is_multiple_choice? %}

    <label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>

    {% collection_select custom_field_id, custom_fields.signup[custom_field.slug].multiple_choice_options, class:"select" %}

    {% endif %}

  </div>

</div>
 
{% endfor %}

Liquid to request individual custom people fields

The Liquid code needed for each custom people field type is listed here:

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

Text fields

{% text_field "signup.custom_values.slug" %}

Number fields

{% text_field "signup.custom_values.slug" %}

Check box fields

{% check_box "signup.custom_values.slug" %}

Multiple choice fields

{% collection_select "signup.custom_values.slug", custom_fields.signup.slug.multiple_choice_options %}

📌Note: The signup.  prefix before custom_values  is not required on the signup page type and should be removed.

To make a text or number field required, add the HTML5 required attribute, as follows:

{% text_field "signup.custom_values.slug", required: "required" %}

Liquid to display individual custom people fields

Custom people field values can be displayed using the custom_values_for_display  Liquid variable. For example, the following will return all of the custom field values for the current user of the page:

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

{{ request.current_signup.custom_values_for_display }}

It's also possible to display a specific custom field by scoping the output to its associated slug:

{{ request.current_signup.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields on a user's profile page, you'll want to use the 'profile.' prefix:

{{ profile.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields in an email, you'll want to use the 'recipient.' prefix:

{{ recipient.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields in a custom walk sheet, you'll want to use the signup.  prefix:

{{ signup.custom_values_for_display['custom_field_slug'] }}

Request only one type of custom people field

It is possible to request only custom people text fields. Use:

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

{% for cf in custom_fields.signup %}
{% assign custom_field = cf[1] %} {% assign custom_field_id = 'custom_values.' | append: custom_field.slug %} <div class="row-fluid"> <div class="span12"> {% if custom_field.is_text? %} <label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label> {% text_field custom_field_id, class:"text" %} {% endif %} </div> </div> {% endfor %}

It is possible to request only custom people number fields. Use:

{% for cf in custom_fields.signup %}
 
{% assign custom_field = cf[1] %}
{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

<div class="row-fluid">
<div class="span12">

{% if custom_field.is_number? %}
<label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>
{% text_field custom_field_id, class:"text" %}
{% endif %}

</div>
</div>

{% endfor %}

It is possible to request only people multiple choice fields, which includes yes/no fields. Use:

{% for cf in custom_fields.signup %}

{% assign custom_field = cf[1] %}
{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}
 
<div class="row-fluid">
<div class="span12">
 
{% if custom_field.is_multiple_choice? %}
<label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>
{% collection_select custom_field_id, custom_fields.signup[custom_field.slug].multiple_choice_options, class:"select" %}
{% endif %}

</div>
</div>

{% endfor %}

It is possible to request only custom people true / false fields. Use:

{% for cf in custom_fields.signup %}

{% assign custom_field = cf[1] %}
{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

<div class="row-fluid">
<div class="span12">

{% if custom_field.is_boolean? %}
<label class="checkbox"  for="signup_custom_values_{{ custom_field.slug }}_custom">{% check_box custom_field_id, class:"checkbox" %} {{ custom_field.name }}</ label >
{% endif %}

</div>
</div>

Limiting the number of custom people fields requested

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

Using the liquid limit and offset filters, you can easily control how many fields of a certain type are called to the page the code is placed on. Add the phrase limit:#  and offset:#  to the forloop  you're using to call the custom fields.

Limit the number of custom donation fields requested using the limit filter. The order of the fields requested is determined by the order they are listed in Settings > Defaults > Custom fields > People. You can skip fields and not request them by using the offsetting filter. The request begins at a different point than the first listed field (e.g. offset:1  begins requesting fields after skipping 1 field; offset:2 skips 2 fields, etc).

Request the first 2 custom people fields. Use:

{% for cf in custom_fields.signup limit:2 %}
  <!-- limits output to 2 custom fields^^^ -->

  {% assign custom_field = cf[1] %}
  {% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}
   
  <div class="row-fluid">
    <div class="span12">
    {% if custom_field.is_text? %}
     <label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>
      {% text_field custom_field_id, class:"text" %}
  {% endif %}
  </div>
  </div>
{% endfor %}

Request only the first 4 custom people number fields. Use:

{% for cf in custom_fields.signup limit:4 %}
  <!-- limits output to 4 custom fields^^^-->
 
  {% assign custom_field = cf[1] %}
  {% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}
 
  <div class="row-fluid">
     <div class="span12">
 
      {% if custom_field.is_number? %}
     <label for="signup_custom_values_{{ custom_field.slug }}_custom" >{{ custom_field.name }}</label>
     {% text_field custom_field_id, class:"text" %}
   {% endif %}
 
   </div>
  </div>
 
{% endfor %}

Limiting the custom people fields requested based on field slug

📌 Note: You must look through all the code below and replace 'slug' with the slug of the custom field.

You can use a conditional "if" statement to check if the slug of the custom field contains a specific word:

Request custom people fields with the word "shirt_size" in the slug:

{% for cf in custom_fields.signup %}
{% assign custom_field = cf[1] %}
{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}
{% if custom_field.slug contains "shirt_size" %}

<div class="row-fluid">
<div class="span12">
{% if custom_field.is_text? %} {{ custom_field.name }}
{% text_field custom_field_id, class:"text" %} {% endif %}
</div>
</div>

{% endif %}
{% endfor %}

Related HOWTOs

Did this answer your question?