oshipka/vm_gen/templates/html/_create.html

55 lines
2.9 KiB
HTML
Raw Normal View History

2020-06-04 18:02:34 +02:00
<form action="{{ url_for('create_[[ name|camel_to_snake ]]') }}" method="post">
<input type="hidden" name="_next" value="{{ _next or request.args.get('_next') or url_for('list_[[ name|camel_to_snake ]]') }}"/>
2020-06-08 14:12:56 +02:00
<table>
2020-06-04 18:02:34 +02:00
[%- for column in columns %]
2020-06-08 14:12:56 +02:00
<tr><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-06 13:33:39 +02:00
[%- if column.type in ['relationship'] %]
2020-06-08 16:32:39 +02:00
[% if column.multiple %]
<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 %]
[%- if not column.secondary %]
2020-07-08 14:38:55 +02:00
<option selected="selected" value="">{{ _("Choose...") }}</option>
[%- endif %]
2020-06-08 16:32:39 +02:00
{% if instance and instance.[[ column.name|pluralize ]] is defined %}
2020-06-08 14:12:56 +02:00
{% set [[ column.name|pluralize ]] = instance.[[ column.name|pluralize ]] %}
2020-06-08 16:32:39 +02:00
{% else %}
{% set [[ column.name|pluralize ]] = model_views.[[ column.name ]].model.query.all() %}
2020-06-08 14:12:56 +02:00
{% endif %}
{%- for sub_instance in [[ column.name|pluralize ]] %}
<option value="{{ sub_instance.id }}" {% if model_view.model_name == "[[ column.name ]]" and instance and instance.id == sub_instance.id %}selected="selected"{% endif %}>{{ sub_instance }}</option>
2020-06-07 13:13:14 +02:00
{%- endfor %}
</select>
[%- 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-07-08 14:38:55 +02:00
<option selected="selected" value="">{{ _("Choose...") }}</option>
[%- for value, display in column.choices.items() %]
<option value="[[ value ]]" {% if instance and instance.[[ column.name ]] == "[[ value ]]" %}selected="selected"{% endif %}>[[ display ]]</option>
[%- endfor %]
</select>
[%- elif column.type in ['number', 'int', 'integer', ] %]
<input id="input-[[ name|camel_to_snake ]]-[[ 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" value="1" name="_[[ column.name ]]"
/>
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 ]]"></textarea>
2020-06-06 13:33:39 +02:00
[%- else %]
<input id="input-[[ name|camel_to_snake ]]-[[ column.name ]]"
type="text" name="[[ column.name ]]" autocomplete="off"
/>
[%- endif %]
2020-06-08 14:12:56 +02:00
</td></tr>
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>