2021-05-08 12:24:13 +02:00
|
|
|
<form action="{{ url_for('update_[[ name|camel_to_snake ]]', uuid=instance.id) }}" method="post" enctype="multipart/form-data">
|
2021-05-09 00:05:26 +02:00
|
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
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-08 14:12:56 +02:00
|
|
|
<table>
|
2020-06-04 18:02:34 +02:00
|
|
|
[%- for column in columns %]
|
2020-08-12 13:28:04 +02:00
|
|
|
{% if "[[ column.name ]]" not in disabled_columns %}
|
|
|
|
<tr {% if "[[ column.name ]]" in hidden_columns %}style="display: none;"{% endif %}><td>
|
2020-07-08 14:38:55 +02:00
|
|
|
<label for="input-[[ name|camel_to_snake ]]-[[ column.name ]]">{{ _("[[ column.name ]]") }}</label>:
|
2020-06-08 14:12:56 +02:00
|
|
|
</td><td>
|
2020-06-07 13:13:14 +02:00
|
|
|
[%- if column.type in ['relationship'] %]
|
2020-06-08 16:32:39 +02:00
|
|
|
[%- if column.multiple %]
|
|
|
|
<input type="hidden" name="_m_n_[[ column.name|pluralize ]]" value="" />
|
|
|
|
<select id="input-[[ name|camel_to_snake ]]-[[ column.name ]]" name="_m_n_[[ column.name|pluralize ]]" multiple>
|
|
|
|
[%- else %]
|
|
|
|
<select id="input-[[ name|camel_to_snake ]]-[[ column.name ]]" name="[[ column.name ]]_id">
|
|
|
|
[%- endif %]
|
2021-05-08 14:14:54 +02:00
|
|
|
{%- for sub_instance in model_views.[[ column.to or column.name ]].model.query.all() %}
|
2020-06-07 13:13:14 +02:00
|
|
|
<option value="{{ sub_instance.id }}"
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- if column.multiple %]
|
2020-06-08 15:39:23 +02:00
|
|
|
{% if sub_instance in instance.[[ column.name|pluralize ]] %}selected="selected"{% endif %}>{{ sub_instance }}</option>
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- else %]
|
2020-06-08 15:39:23 +02:00
|
|
|
{% if instance.[[ column.name ]]_id == sub_instance.id %}selected="selected"{% endif %}>{{ sub_instance }}</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 ]]"
|
2020-06-08 18:07:06 +02:00
|
|
|
name="[[ column.name ]]">
|
2020-06-08 12:19:28 +02:00
|
|
|
[%- 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-08 16:32:39 +02:00
|
|
|
[%- elif column.type in ['bool', 'boolean', ] %]
|
|
|
|
<input type="hidden" name="_[[ column.name ]]" value="0" />
|
|
|
|
<input id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
|
|
|
type="checkbox" name="_[[ column.name ]]" {% if instance.[[ column.name ]] %}checked=checked{% endif %}
|
|
|
|
value="1"
|
|
|
|
/>
|
2020-07-08 14:38:55 +02:00
|
|
|
[%- elif column.type in ['long_text', ] %]
|
|
|
|
<textarea id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
|
|
|
|
name="[[ column.name ]]">{{ instance.[[ column.name ]] }}</textarea>
|
2021-05-08 12:24:13 +02:00
|
|
|
[%- elif column.type in ['file', 'audio', 'video', 'image', 'picture', 'img', ] %]
|
|
|
|
<p>{{ instance.[[ column.name ]] }}</p>
|
|
|
|
<input type="file" name="_file_[[ column.name ]]" accept="[[ column.accept ]]">
|
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 14:12:56 +02:00
|
|
|
</td></tr>
|
2020-08-12 13:28:04 +02:00
|
|
|
{% endif %}
|
2020-06-04 18:02:34 +02:00
|
|
|
[%- endfor %]
|
2020-06-08 14:12:56 +02:00
|
|
|
</table>
|
2020-06-04 18:02:34 +02:00
|
|
|
<input type="submit">
|
|
|
|
</form>
|