{% import 'macros/forms.html' as forms %} {% import 'macros/modal.html' as modal %} {% macro chemical_add_form(form, endpoint, method, id) %} {% if id == -1 %} {% set action = url_for(endpoint) %} {% set title = 'Add Chemical' %} {% else %} {% set action = url_for(endpoint, id_=id) %} {% set title = 'Edit Chemical' %} {% endif %} {% set modal_id = 'modal-edit-chemical-' ~ id %} {% set form_id = 'form-edit-chemical-' ~ id %} {% call modal.modal(id=modal_id, title=title) %}
{{ form.hidden_tag() }}
{{ forms.field_row(form.label, 'Name') }}
{{ forms.field_row(form.molecular_weight, 'Molecular weight') }}
{{ forms.field_row(form.owner_id, 'Responsible') }}
{{ form.submit() }}
{{ forms.script_send_form( form=form, form_name=form_id, method=method, message_field=form_id ~ '-messages' ) }} {% endcall %} {% endmacro %}