I'm writing macros to simplify form generation, but I'm having trouble getting the optional macro parameters to work. I have this code that defines a macro and calls it without the last optional parameter:
{%- macro textfld(field, title, class="") %}
{{ startinput(field, 'textfld') }}
<label>{{ t(title) }}</label>
{{ text_field(field, 'class': class) }}
{{ endinput() }}
{%- endmacro %}
{{ textfld('firstName', '_your_first_name') }}
But I'm getting this error:
Phalcon\Mvc\View\Exception: Macro textfld was called without parameter: class
In fact, a copy-pasted documentation example has the same issue:
{%- macro my_input(name, class="input-text") %}
{% return text_field(name, 'class': class) %}
{%- endmacro %}
{# Call the macro #}
{{ '<p>' ~ my_input('name') ~ '</p>' }}