Craft 3 Documentation

Number Fields

Number fields give you a text input that accepts a numeric value.

Settings #

Number fields have the following settings:

The Field #

Number fields will show a text box where you can enter a number:

Templating #

Calling a Number field in your templates will return the number that was entered in the field.

{% if user.birthyear %}
    <p>{{ user.name }} was born in {{ user.birthyear }}.</p>

    {% set age = now.year - user.birthyear %}
    <p>That makes them {{ age }} years old!</p>
{% endif %}