actix-admin/actix_admin/templates/create_or_edit.html

49 lines
2.3 KiB
HTML
Raw Normal View History

2022-05-31 23:13:44 +02:00
{% extends "base.html" %}
{% block content %}
2022-08-05 13:32:08 +02:00
<form method="post" enctype="multipart/form-data">
2022-08-04 09:21:40 +02:00
{% for model_field in view_model.fields -%}
<div class="field">
<label class="{{ model_field | get_html_input_type }}" for="{{ model_field.field_name }}">
2022-08-04 09:21:40 +02:00
{{ model_field.field_name | split(pat="_") | join(sep=" ") | title }}
</label>
{% if model_field.select_list != "" %}
<div class="control">
<div class="select {% if model.errors | get(key=model_field.field_name, default="" ) !="" %}is-danger{% endif %}">
<select name="{{ model_field.field_name }}">
2022-07-26 22:34:33 +02:00
{% if model_field.is_option %}
<option value=""></option>
2022-07-27 00:37:49 +02:00
{% else %}
<option value="" selected disabled>Select</option>
2022-07-26 22:34:33 +02:00
{% endif %}
{% for select_list_item in select_lists[model_field.field_name] -%}
2022-07-27 00:37:49 +02:00
<option {% if select_list_item[0]==model.values | get(key=model_field.field_name, default="" ) %}
2022-07-31 16:33:02 +02:00
selected {% endif %} value="{{ select_list_item[0] }}">{{ select_list_item[1] | split(pat="_") |
join(sep=" ") | title }}</option>
2022-07-26 22:34:33 +02:00
{%- endfor %}
</select>
2022-07-31 16:33:02 +02:00
</div>
2022-07-26 22:34:33 +02:00
</div>
2022-08-04 09:21:40 +02:00
{% else %}
<div class="control">
<input class="{{ model_field | get_html_input_class }} {% if model.errors | get(key=model_field.field_name,default="" ) !="" %}is-danger{% endif %}"
type="{{ model_field | get_html_input_type }}"
2022-08-04 09:21:40 +02:00
value="{{ model.values | get(key=model_field.field_name, default="") | split(pat=" _") | join(sep=" " ) | title }}"
name="{{ model_field.field_name }}"
placeholder="{{ model_field.field_name }}"
aria-label="{{ model_field.field_name }}"
>
</div>
{% endif %}
</div>
{%- endfor %}
<div class="field is-grouped">
<div class="control">
<button class="button is-link" type="submit">Save</button>
</div>
<div class="control">
<a class="button is-link is-light" href="{{ list_link }}">Cancel</a>
</div>
</div>
</form>
2022-05-31 23:13:44 +02:00
{% endblock content %}