0

Im trying to set te default option to a select with the following macro:

{% macro render_sfield(classParent, fieldGiven, classField="", icono="", id="", default="") -%}
  <div class="input-field {{classParent}}">
    <i class="material-icons prefix">{{icono}}</i>
    {{ fieldGiven(class="validate " + classField, id=id, selected=default) }}
    <label for="{{id}}">{{ fieldGiven.label.text }}</label>
  </div>
{%- endmacro %}

but doesn´t work. I also tried with default=default and value=default but nothing works.

What I get is, as ever, the first option that I have in the default Field : turno = SelectField("Turno:",validators=[DataRequired()], choices=[('Matutino', 'Matutino'), ('Vespertino', 'Vespertino')]). Matutino in this case.

In template i´m using it like this:

{% if datos %}
  {{ render_sfield("row", persona_form.turno, icono='schedule', id="turno-empleado", default=datos.turno) }}
{% else %}
  {{ render_sfield("row", persona_form.turno, icono='schedule', id="turno-empleado", default="") }}
{% endif %}

To re-use the template. Do you know how to do this??

0 Answers0