Skip to content

input_unit

The input_unit macro is used to render a unit. It can be used to have more control over how the input control is rendered.

Definition

{% input_unit(unit) %}

Input parameters

unit

string A unit value.

Example

Here is an example of rendering an input control with a unit with the additional help of h-control webcomponents.

{% from "@macros/input_unit.twig" import input_unit %}

<h-control>
    <h-control-label>
        <label for="price">
            Price

            {{ input_unit('$') }}
        </label>
    </h-control-label>

    <h-control-content>
        <h-control-element>
            <h-input controlId="price" controlName="price">
                <h-input-control></h-input-control>
            </h-input>
        </h-control-element>
    </h-control-content>
</h-control>

Macro source code

{% macro input_unit(unit) %}
    <span class="input__unit">{{ unit }}</span>
{% endmacro %}

Form reference