Commit 31f6c86c authored by Serge S. Koval's avatar Serge S. Koval

Fixed #262. Save and continue button for edit views

parent d466862a
...@@ -1090,7 +1090,13 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1090,7 +1090,13 @@ class BaseModelView(BaseView, ActionsMixin):
if validate_form_on_submit(form): if validate_form_on_submit(form):
if self.update_model(form, model): if self.update_model(form, model):
return redirect(return_url) if '_continue_editing' in request.form:
flash(gettext('Model was successfully saved.'))
# Recreate form
form = self.edit_form(obj=model)
else:
return redirect(return_url)
return self.render(self.edit_template, return self.render(self.edit_template,
model=model, model=model,
......
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{% macro extra() %}
<input name="_continue_editing" type="submit" class="btn btn-large" value="{{ _gettext('Save and Continue') }}" />
{% endmacro %}
{% block head %} {% block head %}
{{ super() }} {{ super() }}
<link href="{{ url_for('admin.static', filename='select2/select2.css') }}" rel="stylesheet"> <link href="{{ url_for('admin.static', filename='select2/select2.css') }}" rel="stylesheet">
...@@ -10,7 +14,7 @@ ...@@ -10,7 +14,7 @@
{% block body %} {% block body %}
{% call lib.form_tag(form) %} {% call lib.form_tag(form) %}
{{ lib.render_form_fields(form, widget_args=form_widget_args) }} {{ lib.render_form_fields(form, widget_args=form_widget_args) }}
{{ lib.render_form_buttons(return_url) }} {{ lib.render_form_buttons(return_url, extra()) }}
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment