2020-06-04 18:02:34 +02:00
|
|
|
<form action="{{ url_for('update_[[ name|camel_to_snake ]]', uuid=instance.id) }}" method="post">
|
2020-06-07 15:45:42 +02:00
|
|
|
<input type="hidden" name="_next" value="{{ _next or request.args.get('_next') or url_for('get_[[ name|camel_to_snake ]]', uuid=instance.id) }}"/>
|
2020-06-04 18:02:34 +02:00
|
|
|
[%- for column in columns %]
|
|
|
|
<label for="input-[[ name|camel_to_snake ]]-[[ column.name ]]">[[ column.name ]]</label>:
|
2020-06-07 13:13:14 +02:00
|
|
|
[%- if column.type in ['relationship'] %]
|
|
|
|
<select id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- if column.multiple %]multiple name="_m_n_[[ column.name|pluralize ]]"[% else %]name="[[ column.name ]]_id"[%- endif %]>
|
2020-06-07 13:13:14 +02:00
|
|
|
{%- for sub_instance in model_views.[[ column.name ]].model.query.all() %}
|
|
|
|
<option value="{{ sub_instance.id }}"
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- if column.multiple %]
|
|
|
|
{% if sub_instance in instance.[[ column.name|pluralize ]] %}selected="selected"{% endif %}>{{ sub_instance.name }}</option>
|
|
|
|
[%- else %]
|
2020-06-07 13:13:14 +02:00
|
|
|
{% if instance.[[ column.name ]]_id == sub_instance.id %}selected="selected"{% endif %}>{{ sub_instance.name }}</option>
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- endif %]
|
2020-06-07 13:13:14 +02:00
|
|
|
{%- endfor %}
|
|
|
|
</select>
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- elif column.type in ['choice', ] %]
|
|
|
|
<select id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
|
|
|
name="[[ column.name ]]_id">
|
|
|
|
[%- for value, display in column.choices.items() %]
|
|
|
|
<option value="[[ value ]]" {% if instance.[[ column.name ]] == "[[ value ]]" %}selected="selected"{% endif %}>[[ display ]]</option>
|
|
|
|
[%- endfor %]
|
|
|
|
</select>
|
2020-06-07 15:45:42 +02:00
|
|
|
[%- elif column.type in ['number', 'int', 'integer', ] %]
|
|
|
|
<input id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
|
|
|
value="{{ instance.[[ column.name ]] }}"
|
|
|
|
type="number" name="[[ column.name ]]"
|
|
|
|
/>
|
2020-06-07 13:13:14 +02:00
|
|
|
[%- else %]
|
2020-06-04 18:02:34 +02:00
|
|
|
<input id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
|
|
|
value="{{ instance.[[ column.name ]] }}"
|
|
|
|
type="text" name="[[ column.name ]]" autocomplete="off"
|
|
|
|
/>
|
2020-06-07 13:13:14 +02:00
|
|
|
[%- endif %]
|
2020-06-08 12:19:28 +02:00
|
|
|
<br>
|
2020-06-04 18:02:34 +02:00
|
|
|
[%- endfor %]
|
|
|
|
<input type="submit">
|
|
|
|
</form>
|